Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

I had rewritten the directive, it would be better than old version #7

Closed
wants to merge 4 commits into from

Conversation

zensh
Copy link

@zensh zensh commented May 30, 2013

This version full wrap jQuery UI Sortable Widget. All methods and events is available.

No longer used ngModel, use uiSortable directive like this:

<tbody ui-sortable="myOptions">
   <tr ng-repeat="..."></tr>
</tbody>

$scope.myOptions = {
    options: { // optional
        appendTo: 'parent',
        //other options
        //jQuery UI Sortable Widget Options, the same below. http://api.jqueryui.com/sortable/#option
    },
    events: { //optional
        activate: function( event, ui ) {},
        // other events
        // jQuery UI Sortable Widget Events, http://api.jqueryui.com/sortable/#event
        // All events will be emit by AngularJS
    },
    methods: {}, //optional
        // extend jQuery UI Sortable Widget Methods to AngularJS after initialize. http://api.jqueryui.com/sortable/#methods
        // then you can invoke methods like this: $scope.myOptions.methods.serialize({ key: "sort" });
    items: [] // optional
        // ng-repeat items array reference. Notice that items will be get asynchronous in most cases.
};

@zensh
Copy link
Author

zensh commented May 30, 2013

And I had written another directive uiAutocomplete, it is very powerful. I want push it to angular-ui.

https://github.com/zensh/ui-autocomplete

@jilljenn
Copy link

jilljenn commented Jun 3, 2013

In your demo, you should replace:

http://lib.sinaapp.com/js/bootstrap/2.3.1/css/bootstrap.min.css
http://lib.sinaapp.com/js/bootstrap/2.3.1/js/bootstrap.min.js    

with:

//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css
//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js

And I don't understand why the items attribute seems to be required in the options so that the update correctly occurs. To see a demo, uncomment the incriminated line in this jsFiddle:
http://jsfiddle.net/Le_Sphinx/hKYWr/543/

@zensh
Copy link
Author

zensh commented Jun 3, 2013

It is good idea to use BootStrap CDN.

items is the reference of ng-repeat items so that sortable can synchronous update ng-repeat items

@ProLoser
Copy link
Member

ProLoser commented Jun 3, 2013

I don't think it's better to cram everything into the ui-sortable attribute alone when you could instead leverage ui-event for all events and ng-model for the data. The only thing that would not be explicitly covered are methods, however this is tricky because timing of when these methods become available or when you would want to call them because... confusing.

For instance, lets say you start to drag or drop and you want to do a check and cancel the drop, it perhaps would be better to hook into the event using ui-event and leverage $event or $params to see if you can cancel. Secondly, if you do a deep-watch on the options object, then disabling or enabling or anything else is easily done by simply modifying the options object.

@ProLoser
Copy link
Member

ProLoser commented Jun 3, 2013

Also, we are no longer using ui.directives.whatever as that required global module declarations. Although the providers and config may be changed later (as it's not namespaced very elegantly) the module name is now ui.sortable

@zensh zensh closed this Jun 4, 2013
thgreasi added a commit that referenced this pull request Feb 18, 2014
Merged angular1.2 branch to master
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants