2013-02-16 22 views
1

使用一系列MVC驅動窗體,我希望利用傳統的'@using (Html.BeginForm(...'生成將在基於Bootstrap的模式中呈現的客戶端窗體的方法。 I've found a technique that binds the modal到形式正是如此定義一個Ajax請求/響應方案:將MVC窗體助手綁定到引導模式

<form class="form-horizontal well" data-async data-target="#rating-modal" action="/some-endpoint" method="POST"> 

我知道如何插入類屬性(new { @class="example"}),但我還沒有找到樣本,顯示了我如何應對「數據-async「和」data-target = xxx「。

想知道如果Darin Dimitrov對this question的回答是我需要的部分答案。或者,也許我需要更好地瞭解EditorTemplates as suggested here

回答

2

正如你帶班做:

new { @class="example"} 

對於數據屬性附加傷害可以這樣做:

new { @class="example", data_target="#rating-modal"} 

data_target輸出data-target當剃刀多解釋htmlAttributes參數

+0

感謝 - 但那麼沒有右手價值的'數據異步'呢?我已經嘗試過......,新的{data_async,data_target =「#rating-modal」} //錯誤當前上下文中不存在名稱'data_async',並且新的{data_async = null,data_target =「#rating-模態「}並得到類似的錯誤。嘗試新的{data_async =「」,data_target =「#rating-modal」}將會呈現data-async =「」,但如果沒有出現它自己的問題,我會感到驚訝。 --appreciated – justSteve 2013-02-17 09:16:53

+0

我認爲'new {data_async =「true」,data_target =「#rating-modal」}'應該做這項工作。 http://jsfiddle.net/9mQdH/。 JS只是要求名稱爲「data-async」的屬性,而不管該值是什麼。 – JOBG 2013-02-17 17:10:46

+0

已驗證....感謝您的跟進。 – justSteve 2013-02-19 12:48:44