English 中文(简体)
如何将动态数据添加到 jquery 移动中的弹出中?
原标题:How to add dynamic data to popup in jquery mobile?

我在jquery Mobile中使用了 popoup () () 。

$("#id").popup();

当弹出打开时, 我想添加一些数据到该 id 元素中。 如何?

问题回答

添加到您的 JavaScript :

$("#id").on( popupafteropen , function(){
    // do whatever here
    $(this).append("Add some HTML!");
    $(this).html("Or replace the HTML contents.");
});

见弹出插件的事件:http://jquerymobile.com/test/docs/pages/popup/events.html

$( #id ).attr( data-some ,  some ).popup();

$( #id ).data( some ,  some ).popup();

有关 data ()

所以,在 jQuery 移动中, 如果您正在通过 ajax 电话生成您的链接, 总是有问题。 这是因为在输入时, jQuery 移动会改变关于元素的很多事情 。

此外,无法继续生成多个弹出, 因为, 如果你在像我这样的项目上工作, 你可能会有很多地方需要弹出, 使应用程序变慢。 所以每次有人点击链接时, 我们只弹出一个弹出并更改内容 。

我创造了一个小提琴 看着你的问题 试一试 欢呼

http://jsfidle.net/tanwaniniranjan/0hzco633/3/

html:

<a href="#popupBasic" data-rel="popup" data-transition="flip" class="popupcontentchanger">Open Popup</a>

<div data-role="popup" id="popupBasic" data-overlay-theme="a">
    <a href="#" data-rel="back" data-role="button" data-theme="a" data-icon="delete" data-iconpos="notext" class="ui-btn-right">Close</a>
    <div id="changehere"> <!-- We will be changing content in this div -->

    </div>
</div>

jj 查询 :

//script to change content
$(document).on("click",".popupcontentchanger",function(event){
    var newhtml = $(this).html();
    $(document).on("popupafteropen", "#popupBasic", function (e) {
        $("#popupBasic #changehere").html(newhtml);
    });
});

//script to clear current html in the popup, on closing of popup so that every time it opens, it loads new content, without initially showing the old content. would have been better if jquery mobile added another method: popupbeforeopen :P
$(document).on("popupafterclose", "#popupBasic", function (e) {
    $("#popupBasic #changehere").html(  );
});




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签