creating a jquery plugin that does not break the chain -



creating a jquery plugin that does not break the chain -

i wrote function save headaches when move css around(it converts css strings objects). able utilize drop in .css() function.

jquery.fn.ccss = function(css) { homecoming this.each(function(){ var css_obj = {}; var tmx = ""; ocss = css.split(";"); $.each(ocss, function (index, elem){ tmx = elem.trim().split(':'); if (tmx[0].length > 0) css_obj[tmx[0]] = tmx[1].trim(); }); homecoming $(this).css(css_obj); //return $; }); }; })(jquery);

my problem when utilize in "fluent" notation null error.

uncaught typeerror: cannot phone call method 'addclass' of null

i'm bit confused has returned in order not "break chain"

you may want line number error is. don't think has function. function worked me.

http://jsfiddle.net/r8utv/ << demo

especially since addclass isn't called, unless you're running when phone call function?

ie

$('#test').ccss('bleh...').addclass('foo');

jquery

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -