2010年8月14日星期六

使用ASP.NET+jQueryUI模擬WordPress的drag&drop widgets

有用過WordPress的網友都會知道WP可以靠Drop&Drop去修改網頁上的Widget位置,這做法有利於可以即時顯示排列結果。

既然是Client-Side的技巧,在ASP.NET上,當然可以做到。
有很多JS Framework都有提供UI Subset去給你直接使用,但我則還是使用jQueryUI去自建,因為明白整個Life cycle,由init到complete,我覺得是很重要的。

jQueryUI方面,你需要用上 Draggable + Droppable + Sortable

ASP.NET方面,當儲存後,下次再進入時,當然要還原之前所設定的,這時候你就需要使用BulletedList Control,因為BulletedList其實就是<ol>或<ul>。

先給大家看看效果,其實暫時未盡完美,因為應該當Drop完成的時候,所複製的<li>element已經要有[Edit]/[Delete] buttons,但大家見到我暫時還需要PostBack才正常顯示是因為未完成。

4 則留言:

  1. nice tutorial need the code to implement in my side.

    回覆刪除
  2. Any chance you will be releasing the dashboard code?

    Thanks,
    Genaro

    回覆刪除
  3. hello, will you give option to download the code. i need this.

    回覆刪除