$.fn.misbehave = function () { alert('Oh behave!');}
$('.bad-behavior').misbehave();
?What is gain by adding an extra "object-oriented" wrapper around standard jquery functionality?
$.fn.misbehave = function () { alert('Oh behave!');}
$('.bad-behavior').misbehave();
?What is gain by adding an extra "object-oriented" wrapper around standard jquery functionality?
Even the simple example: #("#foo").missbehave is quite bad:
missbehave has to be defined as a jQuery global behavior on all objects, not something that is specific to every single dom element to which it was assigned:
$("#foo,#bar,#baz").behavior("missbehave") would mean that each of the 3 have potentially 3 different behaviors for missbehave in the same scheme of things, some might not even have those behaviors.
Think more along the lines of the state of a page:
You set a state, which configures behaviors. Execute the behaviors.
Change a state, change behaviors, execute them again.
Makes state management much easier. God I am wishing I had this about 3 weeks ago when I started my current project :)