Click here to Skip to main content
15,911,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
i need to bind menus dynamically based on role, thus i concatinated string with ul & li tags. i need to show the selected text in the label. i added a click event but not fires
code as follows
XML
<div id='jqxWidget' style='height: 30px; display: none;background-color:#e8e8e8'>
    <div id='jqxMenu' style='margin-left: 20px;'></div>
</div>

click event
C#
$('.jqxMenu li').click(function () {
            alert($(this).html()); 
        });

Sample Data binded in jqxMenu div tag
XML
<ul id='mainid'>
 <li><a href=#>Operations</a>
   <ul style='width: 150px;'>
     <li><a href=default.aspx?src=1010>Booking</a></li>
     <li><a href=default.aspx?src=1009>Manifest </a></li>
     <li><a href=default.aspx?src=1002>RunSheet</a></li>
     <li><a href=default.aspx?src=1004>Delivery Updation</a></li>
     <li><a href=default.aspx?src=1007>Recovery</a></li>
     <li><a href=default.aspx?src=100>Local Manifest Branch</a></li>
     <li><a href=default.aspx?src=5501>Extras</a></li>
     <li><a href=default.aspx?src=2300>Bulk Import</a></li>
   </ul>
 </li>
</ul>


for example when manifest is selected it should be dinded to label
Any suggestions

Thanks in advance
Posted

1 solution

As far as I can see, you have this:
HTML
<div id="jqxMenu" style="margin-left: 20px;"></div>

So you give it an id, but you are binding the click event by the div class, which is non-existent:
JavaScript
$('.jqxMenu li').click(function ()


Your solution would either be to bind the div by id:
JavaScript
$('#jqxMenu li').click(function () {
    //Do your thing
}

or give your div the class it needs:
HTML
<div id="jqxMenu" class="jqxMenu" ...=""> ... </div>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900