javascript - dom jquery behavior not functioning -


i have following function works properly:

        $(function() {                 var availabletags  = <? echo htmlspecialchars($jsenc,ent_noquotes,'utf-8');?>;                  $( "input.tags" ).autocomplete({                     source: availabletags                 });         }); 

on pre-existing:<input class="tags"/> function should (an autocomplete list database dump).

now, these inputs exist in <table>, rows can added or removed on fly.

when adding cells table following:

if(i== document.getelementbyid("soldto").cellindex){ element2.setattribute('class','tags'); }

which makes input (element2) capable of being target (at least thought) of jquery function.

i assuming jquery function not "conscious" of new element , must re-initialized in way see new members.

is true? done @ time of adding new element? sort of $(x).add(mybehavior)?

edit

i tried following:

$("table.inventoryitems").bind("domsubtreemodified", function() { alert('z');      $( "input.tags" ).autocomplete({        source: availabletags       });  }); 

and alert not trigger.

does seem suspicious?

thank you

proper solution external link

jquery autocomplete on element retrieved w/ ajax

try domsubtreemodified event:

$("table").bind("domsubtreemodified", function() {      $( "input.tags" ).autocomplete({         source: availabletags      }); }); 

or can use on() method based on how create new input element:

$("table").on("change", "input.tags", function() {      $(this).autocomplete({         source: availabletags      }); }); 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -