jQuery: Remove Drag and Drop Action from Content Pane of Sortable Portlet Widgets

jQueryUI’s awesome sortable functionality makes it a breeze to create sortable widget dashboards, allowing you to place little widget panes across a number of columns to your heart’s desire. However, the default is that the entire widget or portlet pane forms part of the sortable interface, making it quite a pain when you have something like a horizontal scrollbar on your widget!

Thankfully though, it turns out that it is quite simple to remove the default drag and drop events from certain sections of your widget by simply assigning their identifiers to the cancel option when declaring your sortable setup.

In code:

$(".widgetcolumn").sortable({
            cancel: ".widgetportlet-content"
});

The above basically excludes every element with the class widgetportlet-content from reacting to the drag and drop functionality of the sortable element, giving you more control over the content of your widgets without sacrificing the flexibility that the sortable plugin gives you!

Nifty.

Related Link: http://jqueryui.com/demos/sortable/#portlets

You might also enjoy:

About Craig Lotter

Craig Lotter is an established web developer and application programmer, with strong creative urges (which keep bursting out at the most inopportune moments) and a seemingly insatiable need to love all things animated. Living in the beautiful coastal town of Gordon's Bay in South Africa, he games, develops, takes in animated fare, trains under the Funakoshi karate style and for the most part, simply enjoys life with his amazing wife and daughter. Oh, and he draws ever now and then too.
This entry was posted in jQuery and tagged , , , , . Bookmark the permalink.
    blog comments powered by Disqus