#4406 closed bug (notabug)
Anonymous function keeping previous value of a variable (IE.7)
Reported by: | ryu | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | ui.dialog | Version: | 1.7.1 |
Keywords: | Anonymous Function, storing old value, IE7, dialog box | Cc: | |
Blocked by: | Blocking: |
Description
The issue here is that the anonymous function in the dialog invocation is storing the previous value of a variable named "DestinationObjID".
The 1st click scenario will print out the following:
- "Value outside: ValueOne"
- "Value inside: ValueOne"
The 2nd click scenario will print out the following:
- "Value outside: ValueTwo"
- "Value inside: ValueOne"
HTML ======
1st click: <INPUT TYPE="button" VALUE="Load" onClick="doPopup_Select('<SELECT>', 'ValueOne')">
2nd click: <INPUT TYPE="button" VALUE="Load" onClick="doPopup_Select('<SELECT>', 'ValueTwo')">
JAVASCRIPT
function doPopup_Select(strVal, DestinationObjID){
alert("Value outside: "+DestinationObjID); if(strVal == "<SELECT>"){
$('#selectionDialogBox').dialog({
title: 'Please make a selection', modal: true, buttons:{ "Ok": function() {
var objectVal = $("#selectable").val(); alert("Value inside: "+DestinationObjID); $('#'+DestinationObjID).val(objectVal); $(this).dialog("close");
}}
}); $('#selectionDialogBox').dialog("open");
}
}
That dialog is only initialized once, so on the second call you're not creating a second dialog, you're just displaying the first.