Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOM and model array are not synced #7

Closed
luckylooke opened this issue Aug 17, 2015 · 9 comments
Closed

DOM and model array are not synced #7

luckylooke opened this issue Aug 17, 2015 · 9 comments

Comments

@luckylooke
Copy link
Contributor

When I use your example with ngRepeat:

function ($scope) {
    $scope.many = ['The', 'possibilities', 'are', 'endless!'];
  }

And I change order or remove some items..
How can I get updated 'many' array?

@luckylooke luckylooke changed the title DOM and model array is not synced DOM and model array are not synced Aug 17, 2015
@bevacqua
Copy link
Owner

Do you want to work on this enhancement?

@luckylooke
Copy link
Contributor Author

I can try.. I have one idea how it should be done without modifying dragula
lib itself.
On Aug 19, 2015 4:05 AM, "Nicolas Bevacqua" notifications@github.com
wrote:

Do you want to work on this enhancement?


Reply to this email directly or view it on GitHub
#7 (comment)
.

@bevacqua
Copy link
Owner

Sounds awesome!

@luckylooke
Copy link
Contributor Author

I have one dilema... how do you wish users to provide model to sync with?

dragulaService.options(scope, name, options, model)

or?

@bevacqua
Copy link
Owner

I was thinking we probably should do something like a directive dragula-model='foo', and $eval that on the dragula-scope. That way we get away from the programmatic style and more into the Angular way

@luckylooke
Copy link
Contributor Author

ok, I have also problem with drake events.. I have put listeners in setOptions, but they are not fired.. do you have idea why? I know there is replicator but there can be more than one listener right?

function setOptions (scope, name, options) {
      var bag = add(scope, name, dragula(options));
      if(model !== void 0){ // model to sync with (must have same structure as containers)
        var ctx = getOrCreateCtx(scope);
        var drake = bag.drake;
        console.log('drake', drake);
        drake.on('remove',function removeModel () {
          console.log('removeModel', arguments);
        });
        drake.on('cloned',function clonedModel () {
          console.log('clonedModel', arguments);
        });
        drake.on('drop',function dropModel () {
          console.log('dropModel', arguments);
        });
      }
    }

@bevacqua
Copy link
Owner

You should be able to attach as many event listeners as you'd like. If they're not firing maybe you're attaching the events to the wrong drake?

@luckylooke
Copy link
Contributor Author

@bevacqua yes, that was the cause... I had typo in bag name ;)

@bevacqua
Copy link
Owner

Awesome! Glad you're working on this

bevacqua added a commit that referenced this issue Aug 19, 2015
Fixes #7 - sync DOM with scope.model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants