DailyJS

jQuery Roundup: 1.7 Beta 2, Counter, Templator

Alex R. Young

Subscribe

@dailyjs

Facebook

Google+

templates jquery plugins

jQuery Roundup: 1.7 Beta 2, Counter, Templator

Posted by Alex R. Young on .
Featured

templates jquery plugins

jQuery Roundup: 1.7 Beta 2, Counter, Templator

Posted by Alex R. Young on .
Note: You can send your plugins and articles in for review through our [contact form](/contact.html) or [@dailyjs](http://twitter.com/dailyjs).

jQuery 1.7 Beta 2

jQuery 1.7 Beta 2 is
out. It's worth skimming over the whole change log in the announcement
to check for things that may affect your scripts. This release includes
a lot of IE fixes and improvements, for example:

  • #6485 -- Solution for HTML5 issues in IE
  • #10267 -- IE8 and window is(':visible') crashes
  • #10429 -- IE7 – invalid procedure call or argument when calling .removeAttr('contenteditable');
  • #9033 -- (Deferred) try { } finally { } error in IE8
  • #6170 -- jQuery(window).scroll(); causes IE* to scroll to 0,0
  • #6319 -- Regression: stopPropagation inside change handlers in IE is incorrectly applied to keydown event
  • #6593 -- IE8: DOM 0 event handler called twice when a separate handler is attached via jQuery
  • #6667 -- submit event doesn't delegate in IE* under certain conditions
  • #6942 -- jQuery.event.fix causes unnecessary reflows in IE when handling key events
  • #7161 -- Submit event on a form element not unbound properly in IE
  • #7444 -- Submitting form with "Enter" instead of button click on IE8 or IE7 triggers live submit event twice
  • #8157 -- Focusing an already focused text field will prevent the change event from firing in IE
  • #8866 -- IE8 input[type=file] delegated change event files only on blur
  • #9593 -- Delegated submit event is not instanceof jQuery.Event in IE
  • #9570 -- Selector \$('form[name=".."]') returns zero elements in IE8 under some conditions

There are 68 fixes and improvements altogether; 15 are for IE support.

jQuery Word and Character Counter

Counter (License: MIT) by Wilkins Fernandez is a word and character counting plugin that works a little
bit like Twitter. \$(selector).counter(); will add a
character counter to a textarea. It supports lots of
options -- it's possible to enforce the word or character limit by
preventing more text from being entered, or to simply count forever:

// This will simply print the character count forever
$(selector).counter({
  goal: 'sky'
});

$(selector).counter({
  type: 'word'
, goal: 'sky'
});

The thing I've always found challenging about word counting algorithms
is supporting other languages. A naive word count implementation is
likely to get Japanese and Chinese word counts wrong. It would be
interesting to see this supported here (or your favourite JavaScript
algorithm for doing this in the comments).

Templator

Templator (License: AOL) by Nijiko Yonskai is a template manager, and currently supports a wide
range of template languages. It depends on jQuery, and includes support
for mustache.js, jSmart, TrimPath Template, YAJET, and more (look at
Template/lib/ to see what template languages are supported).

It also comes with a caching system:

var Template = new Templator({
    language: 'jSmart', // Supported Languages: jSmart, EJS, Moustache, Trimpath, YAJET, JST, or Empty
    cache: {
        enabled: false,
        life: 32000,
        tick: 1000
    }
});

And has a chainable API:

var Template = new Templator({ language: 'yajet' })
   .storeElement('tmpl', '.tmpl', { foo: 'Hello', bar: 'World!' })
   .partialElement({ partial: '.partial' }, {}, 'tmpl')
   .on('.this')
   .render('tmpl');

It can also be used in a rudimentary fashion without a template
language:

var Template = new Templator({ language: '' });
Template.renderRaw('Hello {name}!', { name: 'World' });