![](/img/trans.png)
[英]add dynamically filterable controlgroup inside collapsible jquery-mobile
[英]jQuery-Mobile controlgroup does not render
我試圖在頁面中插入一個控件組窗口小部件,但是當我調用controlgroup()時,重做是不正確的。 所有預期的按鈕都顯示為鏈接(Chrome 38.0.2125.101 m)。
我假設這是我正在做的事情,而不是錯誤,因為這些演示似乎運行良好。 我缺少步驟了嗎?
這是我的示例代碼: http : //jsfiddle.net/Lwr4mm4v/5/
function Body() {
this.left_buttons = $('<div data-role="controlgroup"></div>').appendTo( 'div' );
this.save_button = $('<a href=# data-role="button" id="save">save description</a>').appendTo(this.left_buttons);
this.run_button = $('<a href=# data-role="button" id=\"exec\">run description</a>').appendTo(this.left_buttons);
this.stop_button = $('<a href=# data-role="button" id=\"stop\">stop description</a>').appendTo(this.left_buttons);
this.add_button = $('<a href=# data-role="button" id="add">add state</a>').appendTo(this.left_buttons);
this.left_buttons.controlgroup();
}
var test = new Body();
謝謝
您正在使用舊版本的JQM,它需要調用附加方法.trigger("create")
。
建議您使用JQM 1.4.4,而不必使用任何其他方法。
JQM 1.3: http : //jsfiddle.net/Lwr4mm4v/6/
JQM 1.4: http : //jsfiddle.net/4dfu9vtu/
查看最新的文檔,其中添加了一個class =“ ui-btn”來錨定要用作按鈕的元素。
這是一些實現您的目標的示例代碼:
function Body() {
this.left_buttons = $('<div data-role="controlgroup" data-type="horizontal"></div>').appendTo('#root');
this.save_button = $('<a href="#" id="save" class="ui-btn ui-corner-all">Save</a>').appendTo(this.left_buttons);
this.run_button = $('<a href="#" id="exec" class="ui-btn ui-corner-all">Run</a>').appendTo(this.left_buttons);
this.stop_button = $('<a href="#" id="stop" class="ui-btn ui-corner-all">Stop</a>').appendTo(this.left_buttons);
this.add_button = $('<a href="#" id="add" class="ui-btn ui-corner-all">Add</a>').appendTo(this.left_buttons);
this.left_buttons.controlgroup();
}
var test = new Body();
我建立了一個新的示例說明性jsFiddle,可以在這里找到:
另請參閱有關使用“ Controlgroup Widget”的此文檔:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.