angularjs - Converting angular-dragdrop to work with firebase $asArray -


pretty new angularjs , firebase here, trying convert angular-dragdrop.js per following link below work angularfire 0.8.0 $asarray feature:

https://github.com/codef0rmer/angular-dragdrop/blob/master/src/angular-dragdrop.js

i wondering if following changes sufficient:

1) include firebase within function declaration

(function (window, angular, firebase, undefined) { 

2) include $firebase within jqyoui callback function

var jqyoui = angular.module('ngdragdrop', []).service('ngdragdropservice', ['$firebase', '$timeout', '$parse', function($timeout, $parse) { 

3) change "push" , "splice" update on dropmodelvalue , dropmodelvalue $add , $remove instead.

dropmodelvalue.$add(dragitem); 

4) add $save after dropmodelvalue , dropmodelvalue assignments

dragmodelvalue[dragsettings.index] = dropitem; dragmodelvalue[dragsettings.index].$save(dragsettings.index); 

your appreciated. in advance.

you can utilize $extendfactory override push/splice behaviors instead of hacking on drag drop lib. ideally, update priority on records , let server move them.

keep in mind firebase data json object (not array , therefore not ordered in javascript), moving items in array has no effect on position on server. must use priorities if want enforce order on data, other lexicographical sorting keys.

also, aren't using $save correctly--you call array.$save(item), not item.$save(itemindex). judging these misconceptions, there lots of other issues. trip through angular guide , firebase js guide great primer here.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -