jquery - Can't work with DOM elements after AJAX call -


i have large ajax response inserts amount of html. after can't work of newly created ids or classes if present when form loaded.

i have looked .live() solves 1 of problems not other.

i want show div either id or class inserted via ajax .html() when link clicked.

example:

code:

html_out = "<div class='span-1'><a href='#' onclick='show_sub_row(\"#sub_row" + id + "\"); return false;'>[ + ]</a></div>"; html_out += '<div class="hidden_sub_row prepend-2" style="display: none;" id="#sub_row' + id + '">'; html_out += 'content'; html_out += '</div>'; $('#search_results').html(html_out); 

then after html created try:

function show_sub_row(sub_row) {  $(sub_row).show('fast'); } 

i know referencing correct id since can alert(sub_row) , shows correct id matches id shown using firebug inspect hidden div.

unless sub_row initialized var somewhere outside of code have represented here, block should be:

function show_sub_row(sub_row) {  $('#sub_row').show('fast'); } 

also, actual html id sub_row contains # character may make more difficult pinpoint real issue. modify to:

html_out += '<div class="hidden_sub_row prepend-2" style="display: none;" id="sub_row' + id + '">';


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -