简体   繁体   English

如何使用jQuery移动弹出窗口?

[英]How do I use jQuery mobile popup?

I am attempting to using the JQuery Mobile Popup from a callback function of an ajax post. 我正在尝试从ajax帖子的回调函数使用JQuery Mobile Popup。 My callback function has data called "msg" which is a string, typically saying "Save Succesful". 我的回调函数有一个名为“ msg”的数据,该数据是一个字符串,通常显示为“ Save Succesful”。 Any examples out there that allow me to open and close either a popup or a dialog with that message? 有没有允许我打开和关闭带有该消息的弹出窗口或对话框的示例? Here is what I have so far: 这是我到目前为止的内容:

$.post('/Home/SaveSomething', { data: someData },
                function (msg) {
                    //OPEN THE DIALOG
                });

Thank you. 谢谢。

$.post('/Home/SaveSomething',
       { data: someData },
                function (msg) {
                    //OPEN THE DIALOG

                     // you can use alert 
                    alert(msg);
                    // or for custom popup need to use css and jquery coding

});

You may try this 你可以试试这个

    <div data-role="popup" id="popup-message" data-theme="a" data-overlay-theme="a" class="ui-content">
          <a href="#" data-rel="back" data-role="button" data-theme="a" data-icon="remove" data-iconpos="notext" class="ui-btn-right">Close</a>
    </div>

Have a empty popup container for the message as above and use container's id to fill data from the ajax success function as below 如上所述,为该消息提供一个空的弹出容器,并使用容器的ID来填充来自Ajax成功函数的数据,如下所示

$.post('/Home/SaveSomething', { data: someData },
    function (msg) {

    $('#popup-message').text(msg); //fill the data here
    $('#popup-message').popup("open"); // open the popup
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM