# $(”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
It's called message passing. It used to be part of the commonly accepted definition of OO.
JQuery » jQuery UI v1.5 Released, Focus on Consistent API and Effects
11–16 of 16 posts
Re: JQuery » jQuery UI v1.5 Released, Focus on Consistent API and Effects
#12# $(”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
It's called message passing. It used to be part of the commonly accepted definition of OO.
Re: JQuery » jQuery UI v1.5 Released, Focus on Consistent API and Effects
#13# $(”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
I think they ended up having to do that because of jQuery's chaining support. Most of jQuery's functionality lives in a single namespace (jQuery.fn) which means you can chain method calls together like this: 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 q…
If you call a.destroooooy() then you'll get a js error, but if you call a.execute("destroooooy")...
Re: JQuery » jQuery UI v1.5 Released, Focus on Consistent API and Effects
#14# $(”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
I think they ended up having to do that because of jQuery's chaining support. Most of jQuery's functionality lives in a single namespace (jQuery.fn) which means you can chain method calls together like this: 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 q…
I wonder however if a plugin could define its own namespace, like:
$('blah').draggable().create({options}).css(..)...
$('blah').draggable().destroy().css(..)...
draggable() returns a wrapper that exposes only the dragging specific methods, but the underlying jQuery is passed through and returned by any method called on the wrapper. That way you don't have to add all methods in the same namespace.On second thought I don't know if this wouldn't just be confusing :-)
Re: JQuery » jQuery UI v1.5 Released, Focus on Consistent API and Effects
#15Earlier quoted context omitted.
I think they ended up having to do that because of jQuery's chaining support. Most of jQuery's functionality lives in a single namespace (jQuery.fn) which means you can chain method calls together like this: 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 q…
I still don't like it in terms of taste. I guess one question would be how does it handle a typo in the string. If you call a.destroooooy() then you'll get a js error, but if you call a.execute("destroooooy")...
Re: JQuery » jQuery UI v1.5 Released, Focus on Consistent API and Effects
#16I haven't had the chance to use jQuery, how does it compare to other JavaScript libraries such as MooTools or Prototype?
One big difference is that both Prototype and mooTools make modifications to the built-in types (extra Array methods etc). jQuery (and Dojo and YUI) explicitly avoids doing this for compatibility reasons. It's no coincidence that mooTools and Prototype are the only two big libraries that can't co-exist on a single page. The interesting thing about jQuery is its focus - it almost exclusively works to improve the inter…
$('div').draggable().create({Object hash}).draggableDestroy();
It may look awkward at first but I think it will a result into a new win in the long run. I'm having alot of trouble downloading the new library for some reason but can you do something like this?
$('div').draggable().create({Object hash},function(){ alert(Object Creation confirmed}; ).draggableDestroy();
I think the ability to launch a callback function on the creation of a object could open oppurtunities for better UI feel and responsiveness.