I actually agree strongly with you: plugins should be chainable. But
not all are (even some jQuery methods are not, like the ones that
return text [val(), html() etc. without arguments]).
On Dec 12, 9:47 pm, "Brian Cherne" <[EMAIL PROTECTED]> wrote:
> I want to disagree with Danny's first stateme
I want to disagree with Danny's first statement... if you're going to create
a jQuery plug-in (re-usable and useful to all) then it's best to follow the
convention of returning the elements it's acted on. If you want it to return
something else (or nothing) don't create a plug-in -- instead create
If you have no reason to chain your plugin (something like $
('#photo').photo(...).css(...).attr(...) then having it return a
different object makes sense. But then, why put it in the jQuery
namespace at all? 'return new smaon.photo(...) makes as much sense.
Danny
On Dec 12, 10:38 am, Smaon <[EMA
Thank you for your answer Danny.
I'm currently trying this way:
jQuery.fn.photo = function (...) {
var canvas = $(this).get(0);
return new jQuery.photo(canvas, settings);
}
jQuery.twistMap = function(canvas, settings){
//create code
this.crop = function(){
It sounds like you want a way to create namespaces for plugins. There
isn't an "official" way, but I wrote a small function to create
namespaces that was discussed on a previous thread:
http://www.nabble.com/Re%3A-passing-this-p13540912s27240.html
Also, it looks like your functions jQuery.Photo.c
5 matches
Mail list logo