【问题标题】:jquery-mobile button not displaying in scriptjquery-mobile 按钮未在脚本中显示
【发布时间】:2012-10-28 22:40:00
【问题描述】:

我有以下代码按预期工作,除了移动按钮没有显示。

div id="items">     
 <script id="item-template"  type="text/template">    
         <input type="checkbox" id="toggle" {[ print( done ?  '' : 'checked') ]} />
         <span class="text">{{ text}}</span> 
         <a id="save" data-role="button" data-inline="true" data-icon='plus'>Save</a>

我已经尝试打印出按钮等,但 querymobile 按钮在脚本中不起作用吗?

欢迎任何建议

【问题讨论】:

  • 所以你的意思是,一旦我从主干传递了所有值,我需要刷新包含数据的 div?

标签: javascript html jquery-mobile backbone.js


【解决方案1】:

您可以将函数传递给模板并在 onclick 事件上调用它,如下所示:

var tpl = _.template( $("#item-template").html(), {fn : function() {alert("clicked!");} );

在模板中:

<a href="#" id="save" onclick="<% fn() %>" > Save </a>

【讨论】:

  • 抱歉响应慢,像这样传回函数有什么好处。可以自动化吗?
  • 糟糕!对此感到抱歉。我认为您使用 undersocre.js 作为模板引擎!
猜你喜欢
  • 2015-03-16
  • 2013-02-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-12
  • 2011-11-01
相关资源
最近更新 更多