implemented 'run' databinding for use with things like .animate (ticket #39) #40

Closed
wants to merge 4 commits into
from

Projects

None yet

2 participants

@troygoode
Contributor

No description provided.

@weepy
weepy commented on a97c666 Apr 4, 2012

nice - so it's a kinda no-op binding. maybe call or run might be a better name ?

weepy replied Apr 4, 2012

there's also onbind currently - what's the difference here ?

Owner

can you show me an example of how one would use onbind? also, I do like run better than element, yes

weepy replied Apr 4, 2012

.. so I've been using it to setup drag handlers for instance.

Owner

I looked through the o_O.js source and only found two references to onbind. I wasn't able to figure out how to use it...

weepy replied Apr 4, 2012

so here's some example code.

...
Model.prototype.onbind = function() {
    var self = this
    $(this.el).find('.loopL')
        .drag(function(e, dd) {
          var params = self.params()
            var val = dd.offsetX.snap(params.snapX*params.sizeX, 0.2) / params.sizeX
        self.loopL(val)
        }, {relative: true, distance: 2})
        .drag("end", function(e, dd) {
          var params = self.params()
          var val = (dd.offsetX/params.sizeX).snap(params.snapX)
          self.model().loopL(val)
        })
...

the point is that it's only run once and won't get called again when a dependency is changed. perhaps it could be called once, but I'm not sure

@weepy weepy closed this Apr 5, 2012
@weepy
Owner
weepy commented Apr 5, 2012

OK - I've pulled this in under the name call

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment