问题:我有非常长的文本字段,我正在截短它们,并将完整的文本放入一个jQuery手机弹出窗口中,该弹出窗口将在点击“更多”链接时出现。但是,在用弹出标记替换文本后,我很难找到正确的钩子来初始化弹出窗口。我将其绑定到pageinit,但当我单击时,什么也没有发生。完全不绑定替换代码会给我一条消息:"Function called on popup that Not be initialized",所以我知道一些初始化是必要的--但如果不是在pageinit中,我不知道在堆栈中多早需要调用它。
JSFiddle:http://jsfiddle.net/KSFyn/1/ -注意:由于JSFiddle的内置jQuery移动版是1.1.1,pageinit的性能并不像预期的那样好,但这让你对我想要实现的目标有了一个大概的了解。
发布于 2012-11-20 08:16:02
像这样的东西能工作吗?
更新:需要重新创建jQM标记,因为您在创建页面后动态添加弹出文本(使用JQM ~beh中的'create‘事件)
HTML
<div data-role="page" class="type-home">
<div data-role="content">
<a href="#popupInfo" data-rel="popup" data-role="button" data-inline="true">This is an exceptionally long span ...</a>
<div data-role="popup" id="popupInfo" class="ui-content" data-theme="e" style="max-width:350px;">
<p>This is an exceptionally long span that I will attempt to break up with JS and present the full text as a popup. This is an exceptionally long span that I will attempt to break up with JS and present the full text as a popup.</p>
</div>
</div>
</div>
https://stackoverflow.com/questions/13461432
复制相似问题