I don't have a place to put up a demo page since it's a internal
project for the company where I encountered the problem. I agree that
it's sort of hack to replace the plugin's event handler with mine, but
that's the only solution I can think of (unless I can re-order the
event handlers so mine get invoked first).

The more specific detail of the problem:
I am using the datePicker plugin, which creates a clickable link and
registers an event handler like this:
                                                controller.button = $('<a 
href="#" class="dp-choose-date"
title="' + $.dpText.TEXT_CHOOSE_DATE + '">' +
$.dpText.TEXT_CHOOSE_DATE + '</a>')
                                                                .bind(
                                                                        'click',
                                                                        
function()
                                                                        {
                                                                                
// code to display the calendar popup
                                                                        }
                                                                );
                                                $this.after(controller.button);

When the created <a> element is clicked, the above handler function is
invoked and the datepicker calendar popup is shown. I need to change
the start / end dates of the calendar object before it is displayed,
so I tried to add my click handler on the same <a> element. However,
mine got called after the above handler so that didn't work. That's
why I turned to replace the above handler function and then I
discovered that I can't seem to get a reference of the handler because
it is registered via the jquery bind() call.

The question is actually separated with the above problem. Many event
handlers are registered using the bind() call. In those cases, how can
we further manipulate them using JQuery? Such as replace them, or
change the invoking order of these handlers?

Thanks,

On Jul 21, 9:02 am, Dave Methvin <[EMAIL PROTECTED]> wrote:
> > What I am trying to do now is to save a reference of the plugin's handler,
> > unbind it, add my handler which will do my stuff then invoke the plugin's
> > handler. But I can't seem to be able to get the reference of the plugin's
> > handler since it is registered through the bind() call.
>
> Can you post a page that shows what you are trying to do? Maybe there
> is a better way.
>
> If the plugin is meant to be a reusable component, it seems like
> having the more specific page click handler call the plugin's click
> handler is not very elegant.
>
> If the page's click handler always needs to request the plugin to do
> something, maybe it would be better to have the click handler trigger
> a custom event on the element rather than try to mooch off the click.
>
> Inside a handler, you can reference the handler function object using
> arguments.callee if that turns out to be useful.

Reply via email to