gpt4 book ai didi

jquery - 为什么 Handlebarsjs 模板缺少 jquery mobile CSS 样式?

转载 作者:行者123 更新时间:2023-12-01 02:13:10 24 4
gpt4 key购买 nike

我在 jquery 移动页面中使用 Handlebarsjs,当我从服务器发回数据时,它会插入到模板中...但是没有任何 jquery 移动 CSS 样式应用于模板内的代码.

我的模板如下所示:

            <script id="card_list_template" type="text/x-handlebars-template">
{{#each this}}
<li>
<a href="#">
<img src="{{path}}" />
<h3>{{first_name}}&nbsp;{{last_name}}</h3>
<p>Card Owner:&nbsp;{{user_id}}</p>
</a>
</li>
{{/each}}
</script>

上面的代码块被插入到这个无序列表中:

<ul id="search_results" data-role="listview" data-theme="a">

data-role="listview"应该对列表项应用某种样式,但它不适用于通过模板生成的项。

最佳答案

如果您在元素上调用.trigger('create'),它应该应用样式。

示例:

var template = Handlebars.compile(source);
var html = template(output);
$('#handlebarsData').html(html);
// Applies jQuery Mobile styles
$('#handlebarsData').trigger('create');

关于jquery - 为什么 Handlebarsjs 模板缺少 jquery mobile CSS 样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11706750/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com