jQuery移动触发器创建方法 [英] jquery mobile trigger create method
问题描述
我想知道动态注入表格后如何调用.trigger("create")
方法.
我在jquery移动文档中发现了这个
$("...new markup that contains widgets...")
.appendTo(".ui-page")
.trigger( "create" );
但是,(由于我的有限知识)我不知道该用什么替换包含小部件的新标记... -是我正在使用的表的ID吗? /p>
这是我到目前为止尝试过的内容:
JS
$(".ui-responsive").trigger("create");
如何注入HTML
{
title:'test-jqry',
content:'<table data-role="table" id="testjqtable" data-mode="reflow" class="ui-responsive table-stroke jqm-table"><thead><tr><th data-priority="1">Rank</th><th data-priority="persist">Movie Title</th><th data-priority="2">Year</th><th data-priority="3"><abbr title="Rotten Tomato Rating">Rating</abbr></th><th data-priority="4">Reviews</th></tr></thead><tbody><tr><th>1</th><td><a href="http://en.wikipedia.org/wiki/Citizen_Kane" data-rel="external">Citizen Kane</a></td><td>1941</td><td>100%</td><td>74</td></tr><tr><th>2</th><td><a href="http://en.wikipedia.org/wiki/Casablanca_(film)" data-rel="external">Casablanca</a></td><td>1942</td><td>97%</td><td>64</td></tr><tr><th>3</th><td><a href="http://en.wikipedia.org/wiki/The_Godfather" data-rel="external">The Godfather</a></td><td>1972</td><td>97%</td><td>87</td></tr><tr><th>4</th><td><a href="http://en.wikipedia.org/wiki/Gone_with_the_Wind_(film)" data-rel="external">Gone with the Wind</a></td><td>1939</td><td>96%</td><td>87</td></tr><tr><th>5</th><td><a href="http://en.wikipedia.org/wiki/Lawrence_of_Arabia_(film)" data-rel="external">Lawrence of Arabia</a></td><td>1962</td><td>94%</td><td>87</td></tr></tbody></table>'
}
以下是演示: http://jsbin.com/umatel/1/edit
根据jQuery Mobile的 希望这可以清除一切. I was wondering how I'd call I found this in jquery mobile docs But, (due to my limited knowledge) I do not know what I must replace new markup that contains widgets... with - is it the ID of the table I'm using? Here's what I've tried till now : JS How the HTML is injected
Here's a demo : http://jsbin.com/umatel/1/edit According to jQuery Mobile's docs, you cant call Hope this clears things up. 这篇关于jQuery移动触发器创建方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!.trigger("create")
method after injecting a table dynamically.$("...new markup that contains widgets...")
.appendTo(".ui-page")
.trigger( "create" );
$(".ui-responsive").trigger("create");
{
title:'test-jqry',
content:'<table data-role="table" id="testjqtable" data-mode="reflow" class="ui-responsive table-stroke jqm-table"><thead><tr><th data-priority="1">Rank</th><th data-priority="persist">Movie Title</th><th data-priority="2">Year</th><th data-priority="3"><abbr title="Rotten Tomato Rating">Rating</abbr></th><th data-priority="4">Reviews</th></tr></thead><tbody><tr><th>1</th><td><a href="http://en.wikipedia.org/wiki/Citizen_Kane" data-rel="external">Citizen Kane</a></td><td>1941</td><td>100%</td><td>74</td></tr><tr><th>2</th><td><a href="http://en.wikipedia.org/wiki/Casablanca_(film)" data-rel="external">Casablanca</a></td><td>1942</td><td>97%</td><td>64</td></tr><tr><th>3</th><td><a href="http://en.wikipedia.org/wiki/The_Godfather" data-rel="external">The Godfather</a></td><td>1972</td><td>97%</td><td>87</td></tr><tr><th>4</th><td><a href="http://en.wikipedia.org/wiki/Gone_with_the_Wind_(film)" data-rel="external">Gone with the Wind</a></td><td>1939</td><td>96%</td><td>87</td></tr><tr><th>5</th><td><a href="http://en.wikipedia.org/wiki/Lawrence_of_Arabia_(film)" data-rel="external">Lawrence of Arabia</a></td><td>1962</td><td>94%</td><td>87</td></tr></tbody></table>'
}
trigger
on individual elements. Call it on the parent of the element. In your case that would be div[data-role=page]
. So after you inject your HTML into the page, call trigger like this : //first is the div with data-role set to page. for more info, see demo
$("#first").trigger("create");