0
我有局部視圖:道場不MVC局部視圖工作
<div id="[email protected](ViewData["UniqueId"])" class="agreement-box">
<span>
I read agreement
</span>
<a>
terms of usage
</a>
</div>
<script>
require([
'dojo/dom',
"dijit/form/CheckBox",
"dojo/dom-construct",
"dojo/ready"],
function ([email protected](ViewData["UniqueId"]), [email protected](ViewData["UniqueId"]), [email protected](ViewData["UniqueId"]), [email protected](ViewData["UniqueId"])) {
[email protected](ViewData["UniqueId"])(function() {
[email protected](ViewData["UniqueId"]).placeAt([email protected](ViewData["UniqueId"]).byId("[email protected](ViewData["UniqueId"])"), "first");
});
var [email protected](ViewData["UniqueId"]) = new [email protected](ViewData["UniqueId"])(
{
id: "[email protected](ViewData["UniqueId"])",
name: "[email protected](ViewData["UniqueId"])",
class: "i-agree-checkbox",
checked: false
});
});
</script>
我利用一切形式下,這種觀點(每個表單有一個唯一的ID女巫我作爲ViewData的使用[「唯一ID」]) :
@Html.Partial("../MyPartialView", new ViewDataDictionary { { "UniqueId", "Order" } })
當這個視圖出現在每個頁面上時,它會起作用,但是當它看起來更多時,這個複選框就不會出現在頁面上。我沒有得到任何錯誤,並在鉻調試器的代碼工作!
生成的輸出:
<div id="AgreementBoxContact" class="agreement-box">
<span>
I read agreement
</span>
<a>
terms of usage
</a>
</div>
<script>
require([
'dojo/dom',
"dijit/form/CheckBox",
"dojo/dom-construct",
"dojo/ready"],
function (domContact, checkboxContact, constructContact, readyContact) {
readyContact(function() {
agreecheckboxContact.placeAt(domContact.byId("AgreementBoxContact"), "first");
});
var agreecheckboxContact = new checkboxContact(
{
id: "IAgreeToTermsOfUseContact",
name: "iagreetotermsofuseContact",
class: "i-agree-checkbox",
checked: false
});
});
</script>
//
//on the same html page
//
<div id="AgreementBoxOrder" class="agreement-box">
<span>
I read agreement
</span>
<a>
terms of usage
</a>
</div>
<script>
require([
'dojo/dom',
"dijit/form/CheckBox",
"dojo/dom-construct",
"dojo/ready"],
function (domOrder, checkboxOrder, constructOrder, readyOrder) {
readyOrder(function() {
agreecheckboxOrder.placeAt(domOrder.byId("AgreementBoxOrder"), "first");
});
var agreecheckboxOrder = new checkboxOrder(
{
id: "IAgreeToTermsOfUseOrder",
name: "iagreetotermsofuseOrder",
class: "i-agree-checkbox",
checked: false
});
});
</script>
請幫我看看,爲什麼它的發生!
嘗試用'''dojo/domReady!'代替''dojo/ready''' – ben
我試過了,但是得到了同樣的結果。 – levkaster
不確定要了解這是如何工作的。它是多個複選框下的一種形式或一個複選框跨多個表單? – ben