Simple Modal issues - Multiples, Disappearing Content

后端 未结 3 1410
既然无缘
既然无缘 2021-01-27 15:55

I\'m a jQuery newbie and have rigged Simple Modal to allow me to have more than one modal on a page by doing this in my script:

$(\'input.basic, a.basic\').click(f

3条回答
  •  囚心锁ツ
    2021-01-27 16:31

    When you hide the dialog, jQuery changes the position of the div in the DOM, then wanting to locate it with "$(this).next(...)", you can not do. You should have some ID or a reference to locate otherwise.

    EDIT: Well, you have me thinking a little echo. I hope it is useful the code that I'm going through. I'm not tested:

    $('input.basic, a.basic').click(function (e) 
    { 
       e.preventDefault(); 
       var el = "";
    
       if($(this).data("xid")!=undefined)
       {
          el = $($(this).data("xid"));
       }
       else
       {
         var xid = "xid_" + ((new Date()).getTime());
         el = $(this).next('.basicModalContent');
         $(this).data("xid", xid);
         if (el.lenght>0)
           el.attr("id", xid);
       }
    
       if (el.lenght>0)
       {
         el.modal();
       }
    });
    

提交回复
热议问题