How about setting a global variable such that it will be 'on' when a
function is running, and set back to 'off' when done?
Whenever a function sees that it's 'on' it will not execute.

Aside from that, knowing you have so many elements with an onclick
event, is there any other way to re-work your design so that it can
use the same function?
Javascript doesn't have function overloading (creating functions with
the same name but with different number of arguments), but since you
can pass in as much arguments as you want into a function, you can do
an argument count (or type) check and determine what you want to do.
Alternatively, if possible, store your parameter content separately
(e.g. a JSON object) that can be referenced to from a specific element
(e.g. by an ID).

The reason you'd probably want to combine it into one controller
function is so that you can bind that one controller function to your
page using event delegation. I'm not sure what you're doing now, but I
assume you're binding onclicks one-by-one onto every element. Doing
this with hundreds of elements makes your page load very slow. Event
delegation binds it only once to the parent element of all those
elements. Then when the child element is clicked, it will delegate the
event to the parent. Then you do checks in the function to determine
which child was clicked on (using the event object that's
automatically created), and when you get that, you can act on it along
with the data associated to it.

Here's some reference on event delegation:
http://www.learningjquery.com/2008/03/working-with-events-part-1
http://lab.distilldesign.com/event-delegation/

Hope that helps.

On May 27, 7:58 am, con-man-jake <jakedim...@gmail.com> wrote:
> I am new to jquery and to web development in general.
> I have many elements (over 100) on a page each with an onclick event
> listener function.  They have different listener function names and
> varying number of parameters.  The functions may take a second or two
> to process.  If I click on any one of them, I need to disable the
> mouse click on all the rest until the process is done.
> Using bind() and unbind() is unrealistic (at least as far as my
> limited understanding of them is concerned) because of all the
> different function names and different number of parameters for each.
> I say 'unrealistic', but, of course, I may be way-off here.
> So my question is; is there a jquery trick, a javascript trick or even
> a css trick that can help me do this easily?
> Your help is greatly appreciated.
> jake

Reply via email to