I'm using a grid plugin that I created based on what I've seen of
other plugins. The grid method is added to jQuery and I can create a
grid like so...

var data = [['a', 'b'],['c','d']]
$('#grid').grid({ data: data }).show()

Later, I'm going to need to control the grid...

$('#grid').scrollToRow(6).highLightRow(6)

It seems like a terrible idea to add these methods to the jQuery
object, when they are only going to apply to an element that has
become a grid.

Two ideas to keep things looking like jQuery..

Controller set of methods is returned..

$('#grid').grid().data(data).drig().show()
$('#grid').grid().scrollToRow(6).drig().css("border", "1px")

A controller object is returned..

var grid = null
$("grid").grid({
    data: data,
    onComplete: function(controller)  { grid = controller }
})
grid.srollToRow(6)

What is best practice?

1.) Plugins be restricted to only those methods that effect all
elements, or a well-established set, like form input elements, and
custom UI components are controllers like Prototype,  or
2.) a new plugins state is obtained by method chaining by adding
however many methods to the jQuery namespace, or
3.) a controller set of methods is returned, or
4.) a controller object is returned.

-- 
Alan Gutierrez - 504 717 1428 - [EMAIL PROTECTED] - http://blogometer.com/
                Think New Orleans - http://thinknola.com/

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to