<div id="Comment">
<div id="MyDialog1">
<input Type="hidden" value="1" id="hfDialog1userId"/>
<div>
<!--End of div MyDialog1
-->
<div id="MyDialog2">
<input Type="hidden" value="1" id="hfDialog2UserId"/>
<div>
<!--End of div MyDialog2
-->
<div>
<!--End of div Coment-->
<input type="btn1" onclikc="LoadComentPanel();return false;" value="My Button"/>
Div "Coment" is loaded using jquery ajax
<script type="text/javascript">
$(document).ready(function(){
LoadComentPanel();
//Bind comments with default val
})
function LoadComentPanel()
{
$.ajax({ url:"http://www.myurl.com/MyController/MyMethod",
data: { 'documentId': app.document.id, 'variantId': app.variant.id }
cache: false,
success: function (data) {
$("#Comment").html(data);
alert($("#hfDialog1userId", $("#Comment").html()).val());
//Show value 2 (new value comes from server.)
alert($("#Comment").html())
// Show proper html comes from server with "MyDilog1 and MyDilog2" divs.
commentPanel.bind();
alert($("#hfDialog1userId", $("#Comment").html()).val());
//Show Value 1 (old Value that is bind during page load) ??--> Why values changes to old value that r store in document ready event
alert($("#Comment").html())
// Remove dialog divs from "Comment" div. ??--> Why MyDilog1 and MyDilog2 div remove after dialog is initialize
}
});
}
var commentPanel = {
bind : function (){
$("#MyDialog1").dialog({
title: "Title 1",
autoOpen: false,
modal: true
.
.
open: function(){/*Setting modal property like title,color*/}
close: function(){/*My code*/}
});
$("#MyDialog2").dialog({
title: "Title 2",
autoOpen: false,
modal: true
.
.
open: function(){/*Setting modal property like title,color*/}
close: function(){/*My code*/}
});
}
</script>
problem:
When Ajax Success function is called I get proper data for hfDilog1UserId, hfDilog2UserId from server.
As soon as i call commentPanel.bind() it remove "MyDialog1" and "MyDialog2" from "Comment" div. And when i check "hfDilog1UserId" on dilog open it shows me old value which was store in document read event.
Note:
$("#MyDialog1").dialog and $("#MyDialog2").dialog r initialize ever time after ajax called, other wise dialog is not getting opened on $("MyDialog").dialog("open") method.
Anybody can explain why this is happening...
Any help is appreciated..
Thanks in advanced