1
我是MVC的新手,想要一些高級別的指導。ASP.Net MVC查看更新
我有以下類,一個包含問題列表的文檔。問題有一個訂單屬性來安排每個文件的問題順序。
public class Question
{
public int QuestionId {get; set;}
public string Text {get; set;}
public int Order {get; set;}
}
public class Document
{
public int DocumentId {get; set;}
public string DocumentName {get; set;}
public List<Question> Questions {get; set;}
}
我想表明其問題列表的文檔,並允許用戶點擊一個控制其移動向上或向下在列表中的問題旁邊。
我應該使用哪些組件更新Order屬性,並在更改時在屏幕上反映它?我猜我不需要發佈,直到用戶做出所有更改,但是立即更新視圖的最佳方式是什麼?
你看過jQueryUI,特別是draggable()方法嗎? http://jqueryui.com/demos/draggable/#sortable – paul
什麼會更新Order屬性? jQuery的?你能給我一段代碼更新的財產? – strattonn
當你準備好'POST'時,你只需調用'sortable'元素的'.serialise()'方法,這會給你一個元素新順序的JSON結構,所有這些都可以使用'jQuery.ajax()'。你應該可以通過搜索「jQuery mvc sortable ajax」來找到一些例子 - 例如http://stackoverflow.com/questions/3311938/saving-jquery-sortable-new-order-to-asp-net-mvc-controller – paul