|
|
|
|
|
by axod
6581 days ago
|
|
# $(”div”).draggable() creates a draggable # $(”div”).draggable(”destroy”) destroys it Am I missing something here, or is that an extremely ugly design choice? Passing strings into functions to specify what function you want? eugh |
|
jQuery('div:first').addClass('hello').text('Hello World').draggable().css('color', 'red');
If a plugin needs three or four methods, that's three or four extra functions on the one object - which ends up looking quite ugly:
jQuery('blah').draggable({options}).destroyDraggable()
The message passing idiom lets them add just one method to the jQuery.fn namespace that can cover a full range of different actions. I think it's a pretty clever pragmatic solution.