views:

43

answers:

1

I am working on an interface which involves A LOT of javascript. There is a calendar and blocks drawn on the calendar.

The calendar is a jQuery widget, which works beautifully.

The blocks drawn on top are also jQuery widgets. While it works - I am wondering, every time I create another block, is the widget fully duplicating, or is it referencing the widget?

If I end up with 200 blocks on the screen, do I have 200 copies of the widget? Because if so i'm sure this will impact the performance quite heavily. Also it would determine whether I have functions inside the widget, or have them external to the widget looking in if that makes sense.

Just putting some feelers out there for thoughts. I couldn't find anything by searching online.

A: 

shouldn't be too much of an issue, really. Especially since JQueryUI elements aren't usually very DOM-intesive (as in, it doesn't usually create lots of elements for a 'control').

For your events etc, you should already be defining your handlers as generic functions and binding them, like so:

function dosomethingwithaclick(evt) {
    //
}
$("#myelem").click(dosomethingwithaclick);

one function for all elements, they just reference the same one.

Luke Schafer