javascript - How to override jQuery global functions for my plugin? -


i have created plugin creates check box image based based on hidden field. override is() function... possible? i'm using image mock checkbox.

html:

<input type="hidden" value="1" id="box" /> 

create plugin hidden field:

$('#box').mycheckbox(); 

i able following:

$('#box').is(':checked'); 

is possible override is() function in plugin?

yep :)

           (function() {               var proxied = jquery.fn.is;               jquery.fn.is= function() {                 //do things here                 return proxied.apply(this, arguments);//call default here               };             })(); 

btw :checked supported default

so if u had

$('#checkbox').is(':checked');// return true/false depending if checkbox ticked or not don't on complicate things pull ur hair out later on when u forgot u made overriding changes :)


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -