I'm trying to pass a variable 'edit_id' to a load string but it doesn't seem to be working.
This isn't working:
$('#edit-page-dialog').load('includes/form_add_edit_page.inc.php?add-edit=edit&edit_id=' + edit_id).dialog({
Whereas adding the id into the string like this does work:
$('#edit-page-dialog').load('includes/form_add_edit_page.inc.php?add-edit=edit&edit_id=105').dialog({
This is how I'm setting the edit_id variable:
// edit-page dialog Link
$('.ed开发者_开发问答it-page-link').click(function(){
edit_id = $(this).attr('id');
$('#edit-page-dialog').dialog('open');
return false;
});
Any ideas on what I'm doing wrong? Is it at all possible?
I believe the scope of the variable isn't correct. edit_id
is only used inside the function. Try declaring this variable outside the function and assigning the value then.
var edit_id = 0;
// edit-page dialog Link
$('.edit-page-link').click(function(){
edit_id = $(this).attr('id');
$('#edit-page-dialog').dialog('open');
return false;
});
and then after this function use:
$('#edit-page-dialog').load('includes/form_add_edit_page.inc.php?add-edit=edit&edit_id=' + edit_id).dialog({ })
精彩评论