views:

59

answers:

2

I am dynamically creating divs within a jquery accordion that are loaded with data as when the user clicks on the accordion title. I have this all working except that when I pass the div id into the load details method, the call to .load() does not work. What can I do to fix this? It seems like a simple javascript string eval would work but I can not find what I am looking for.

Code: Here is the basic function:

function loadDetails(div_id) {
   var load_string = "ajax/get_details.aspx";
   $(div_id).load(load_string);
 }

This function is called correctly on the click event and the div_id is passed in correctly but the load function is not working. If I use code like this it work correctly:

$('#test').load(load_string);
+2  A: 

$("#" + div_id).load(load_string);

I'm assuming the div_id being passed in is missing the pound?

zincorp
yes thanks, i knew it would be something simple. I tried something similar but added single quotes around the whole thing and that doesn't work!But this works! SO thanks!
tittatty
No problem. Please be sure to flag answers when someone has resolved your issue. You can do so by selecting the checkmark beside the up/down arrows on the answer.
zincorp
A: 

maby: $('#' + div_id).load(load_string);

http://api.jquery.com/id-selector/

Jarek