【问题标题】:How to enhance a dynamically created Jquery Mobile checkbox?如何增强动态创建的 Jquery Mobile 复选框?
【发布时间】:2012-09-20 18:30:47
【问题描述】:

我正在努力让它发挥作用:

var selectorBox = $('<label for="'+selectorID+'"><input type="checkbox" id="'+selectorID+'" name="'+selectorID+'" class="selector" data-inline="true" data-iconpos="notext"></label>').trigger('create'),
    cell = $( "<th class='persist essential notxtchkbx rowHigh' "+rowSpanner+"></th>" ).append( selectorBox );

currentRow.prepend( cell );

selectorBox 是复选框 HTML,在创建单元格并将此单元格插入表格行之前,我试图通过 trigger("create") 对其进行增强。

问题
如何让此复选框正确呈现?

感谢您的帮助!

【问题讨论】:

  • 我看不出你想用.trigger('create') 实现什么。在没有“创建”事件的情况下,这将什么都不做。
  • 刚刚开始工作。我需要在父元素上调用trigger("create")。在我的例子中是 TH 细胞。直接在checkbox上调用是不行的。
  • 然后在下面发布答案 ;),而不是在 cmets 中。
  • 给我几分钟。马上写出来……

标签: javascript jquery jquery-mobile checkbox render


【解决方案1】:

要增强复选框,您需要在其父元素上调用trigger("create")。直接在复选框上调用它不起作用。只需使用类似的东西:

$("input.myCheckbox").closest("div").trigger("create");

它应该可以工作。

【讨论】:

    猜你喜欢
    • 2016-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多