Ask questions and get good answers on mb.jQuery.components

I have tried to use jQuery.click(), jQuery.bind(), and jQuery.live() to bind a click event handler to the submenu anchors, but these events are not firing. Any help would be much appreciated. Below is a sample of the menu structure and the jQuery code.

<div class="mbmenu menu" id="rootItemMenu">
    <a class="rootMenuItem menuItem modifyitem">Modify Item</a>
    <a class="rootMenuItem menuItem moveitem" menu="projectMenu">Move Item<span>></span></a>
    <a class="rootMenuItem menuItem moveitem">Mark Item Complete</a>
</div>

<div class="mbmenu menu" id="projectMenu">
    <a class="projectMenuItem menuItem">Project 1</a>
</div>

$("a.projectMenuItem").click(clickHandler);

Where

clickHandler
is defined in a JS file that is included in the header of the page.

asked Mar 22 '10 at 14:56

Thomas%20Moyer's gravatar image

Thomas Moyer
111


All the menu shown by the component are clones of the original you wrote in the page; that's why your bind is not fired. At line 317 there's the clone action of the voices; you can try to modify this

from:

  this.voices= $("#"+m).find("a").clone();

to:

  this.voices= $("#"+m).find("a").clone(true);

Adding the boolean should copy the data and the events associated as described in the jQuery doc: jQuery/clone

answered Mar 22 '10 at 15:20

Matteo%20Bicocchi's gravatar image

Matteo Bicocchi ♦♦
1776129

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×3

Asked: Mar 22 '10 at 14:56

Seen: 272 times

Last updated: Mar 22 '10 at 15:20

jQuery main site - Matteo Bicocchi