我一直在試圖使用backbonejs和jqm在一起。骨幹視圖傳遞給jQuery Mobile
我可以呈現主頁面正常。該頁面上有一個用戶可以點擊的列表。所選項目應顯示詳細信息頁面,其中包含所選清單項目的信息。詳細信息頁面是一個骨幹視圖,其中包含在項目的視圖對象中呈現的模板。
詳細信息的視圖.render()生成html ok,並將主頁面的div標記的html設置爲呈現項目的細節標記。它看起來像這樣:
podClicked: function (event) {
console.log("PodListItemView: got click from:" + event.target.innerHTML + " id:" + (this.model.get("id") ? this.model.get("id") : "no id assigned") + "\n\t CID:" + this.model.cid);
var detailView = new PodDetailView({ model: this.model });
detailView.render();
},
詳細信息視圖的渲染看起來像這樣:
render: function() {
this.$el.html(this.template({ podId: this.model.get("podId"), isAbout_Name: this.model.get("isAbout_Name"), happenedOn: this.model.get("happenedOn") }));
var appPageHtml = $(app.el).html($(this.el));
$.mobile.changePage(""); // <-- vague stab in the dark to try to get JQM to do something. I've also tried $.mobile.changePage(appPageHtml).
console.log("PodDetailView: render");
return this;
}
我可以看到詳細的觀點得到了檢查Chrome的開發工具HTML編輯器在網頁上呈現,但它不是在頁面上顯示。我看到的只是一個空白頁面。
我試過$ .mobile.changePage(),但沒有一個URL會引發錯誤。
如何讓JQM將它的類標籤應用到呈現的html中?
的HTML和模板看起來像這樣:
<!-- Main Page -->
<div id="lessa-app" class="meditator-image" data-role="page"></div>
<!-- The rest are templates processed through underscore -->
<script id="app-main-template" type="text/template">
<div data-role="header">
<h1>@ViewBag.Title</h1>
</div>
<!-- /header -->
<div id="main-content" data-role="content">
<div id="pod-list" data-theme="a">
<ul data-role="listview" >
</ul>
</div>
</div>
<div id="main-footer" data-role='footer'>
<div id="newPod" class="ez-icon-plus"></div>
</div>
</script>
<script id="poditem-template" type="text/template">
<span class="pod-listitem"><%= isAbout_Name %></span> <span class='pod-listitem ui-li-aside'><%= happenedOn %></span> <span class='pod-listitem ui-li-count'>5</span>
</script>
<script id="page-pod-detail-template" type="text/template">
<div data-role="header">
<h1>Pod Details</h1>
</div>
<div data-role="content">
<div id='podDetailForm'>
<fieldset data-role="fieldcontain">
<legend>PodDto</legend>
<label for="happenedOn">This was on:</label>
<input type="date" name="name" id="happenedOn" value="<%= happenedOn %>" />
</fieldset>
</div>
<button id="backToList" data-inline="false">Back to list</button>
</div>
<div data-role='footer'></div>
</script>
預先感謝任何建議......這是甚至是可行的?