【发布时间】:2018-12-04 15:08:52
【问题描述】:
当我尝试在 jquery mobile 按钮下方添加 jquery 代码时:
// insert new button to bf div (breackfast div)
$("#bf").html('<a href="FoodCat/FilterIndex?TimeId=2&CurDate=0" data-role="button" > Add new </a> ');
这并不意味着 Jquery 移动风格 (data-role="button") ??
下面是html:
<div data-role="collapsible-set" data-theme="i" data-split-icon="gear" data-split-theme="e">
<div data-role="collapsible">
<h3> Breackfast </h3>
<div id="bf" style="margin:0 !important;padding:0 !important; display:inline !important">
<ul data-role="listview" data-theme="i" ">
<li>
<input type="button" tabindex="@ViewBag.CurInt" id="bdelete" value="DeleteFood" onclick="bfd();"/>
</li>
</ul>
</div>
</div>
</div>
以下是 JQuery 代码(PLZ 注意:它调用服务并执行删除,但问题仅在于不以 jquery 移动样式呈现按钮)
<script type="text/javascript">
function bfd() {
var fp = '/api/service?prsnIduser1&MealTime=2&CurDate='+ $("#bdelete").attr("tabindex");
$.ajax({
url: fp,
type: 'Delete',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
success: function () {
$("#bf").html('<a href="FoodCat/FilterIndex?TimeId=2&CurDate=0" data-role="button" > Add new </a> ');
$("#bf a").buttonMarkup();
});
}
</script>
我在 google 和 stackoverflow 上做了很多搜索,但我在下面尝试但没有成功:
$("div[data-role=collapsible]").collapsible({refresh: true });
// or even add :
$("#bf").page();
// or
$("#bf a").buttonMarkup();
【问题讨论】:
-
这是你想要达到的吗? jsfiddle.net/Palestinian/qYLVb
标签: jquery html css jquery-mobile jquery-mobile-button