javascript - JQuery list append item not selectable -


i have weird issue jquery append list.

<ul id="idnicheitems" class="clscrollitems ui-widget-content ui-corner-all">     <li id="nicheitem_1"> item 1</li>     <li id="nicheitem_2"> item 2</li>     <li id="nicheitem_3"> item 3</li>     <li id="nicheitem_4"> item 4</li> </ul> 

the list part of list box type control using

 $("#idnicheitems li").hover(function(){     $(this).addclass("cllisthighlight");       },function(){$(this).removeclass("cllisthighlight");}); 

this works fine.

after json query later on append new item list . when inspect using firebug looks every other item in list - ids unique - looks fine.

the trouble can not highlight or select it.

my thoughts have call above "$("#idnicheitems li"). hover ..again attach hover function after inserting node - not seem work - unless have bug in bug fix.

am on right track?

answered own question - rep lower earthworms belly button - may of use else wont delete it.

looks had bug in bug fix or dirty cache - of course fixed 20 seconds after posting....

anyway lesson day. after inserting new item using jquery append prepend etc existing list or collection of items have behavior associated them - not forget attach behavior new item.

in other words call whatever selector code called on original items new items.

you can user live(),it's binding root node of dom tree rather element:

$("#idnicheitems li").live('mouseover',function(){$(this).addclass("cllisthighlight")}); $("#idnicheitems li").live('mouseout',function(){$(this).removeclass("cllisthighlight")}); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -