How to extend a jquery ui widget ? (1.7)

前端 未结 6 1384
终归单人心
终归单人心 2020-12-08 00:40

I would like to create a custom version of the sortable widget. I have been searching for documentation, but could not find something really accurate. The best information I

6条回答
  •  青春惊慌失措
    2020-12-08 01:33

    I'm using this in order to predefine start, stop and update functions:

    $.widget('ui.custom_sortable_or_any_other_name', $.ui.sortable, {
        _init: function() {
            this.element.children().css('position', 'relative'); //for example
        },
        options : {
            start: function (event, ui) {   
                ui.item.addClass('noclick'); //ui.item get's the item, that's my point
            },
            stop: function (event, ui) {            
            },
            update: function (event, ui) {
                $.ajax(); //some ajax you might want to do
            }
        }
    });
    

提交回复
热议问题