I'm loading another jquery load() method after showing a jQuery ui dialog on click of a product:
$(".productCode").on('click', function() {
var productCode = $(this).text();
var userId = jQ( '#field_user_id option:selected' ).val();
var accountParam = $('#accCode').val();
var branchParam = $('#branchCode').val();
var getUrl = "http://admin.myapp.com/inventory_mgmt_uploads/product_details/" + productCode + "/" + userId + "/" + accountParam + "/" + branchParam;
console.log( getUrl );
showUrlInDialog( getUrl );
});
Now here's how I show the jQuery UI dialog:
function showUrlInDialog( url ) {
var tag = $("<div></div>");
$('#imgLoader').show();
$.ajax({
url: url,
success: function( data ) {
tag.html(data).dialog({
modal: true,
title: "Product Inventory Details",
width: 600,
height: 600
}).dialog('open');
$('#imgLoader').hide();
showBeginningInventories();
}
});
}
...and here's the function that executes the load method.
function showBeginningInventories(){
console.log('computing beginning inventories.');
var selectedText = $('#selectUom').find('option:selected').text();
var productCode = $('#pDetailsProdCode').text();
var userId = $('#pDetailsUserId').text();
var url_to_load = "http://admin.myapp.com/inventory_mgmt_uploads/compute_inventories/" + productCode + "/" + userId + "/acc-mer3249/br-1/" + selectedText;
console.log(url_to_load);
$( "#begInv" ).html("<i>Loading...</i>");
$( "#begInv" ).load(url_to_load, function() {
console.log('done loading.');
});
}
please note that this is just a sample code, and i know i should be using jQuery on() method instead of live().
the code above works on first click of a product code, but on the second click/reload, it does does not do showBeginningInventories() properly.
on my console, it says showBeginningInventories() was executed, but the loaded html is not showing...
any ideas? thanks for any help!
pDetailsProdCodeare inside the dialog