开发者

Jquery dialog "cache" variable. How avoid it?

I have a dialog confirmation that must be reused for several controls in a html page.

Each change in a select, fire this dialog.

This is my code:

  console.info("before:" + select[0].id);
  dialog = $('#dialogReject').dialog(
  {
    autoOpen:false,
    height:300,
    width:400,
    modal:true,
    button开发者_运维技巧s:
    { "Ok":
      function() {
        console.info("after:" + select[0].id);
      },
    } 
  });

  dialog.dialog('open');

So, I have 2 selects. I change the first, show the dialog. The id in before & after are equal.

I select the second, change it and show the dialog. Now in before the correct id is displayed but in after is the id of the first select.

How avoid this?


Im not sure I entirely understand the question, but if you are trying to change content in a dialog you will probably need to .destroy() it after it was called the first time. Let me know if this isn't helpful and hopefully I/someone else can shed some more light on it.

Edit: That wording was vague. What I meant by that was try calling the .destroy() method when you close the dialog and you should have no problem with 'caching'.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜