jquery - is it possible to add new events in a ember view -



jquery - is it possible to add new events in a ember view -

i have little application, user can place divs on stage.

these divs have draggable (and resizable) (via jquery ui), farther selection of events should fired, when user interacts div (via hammer.js).

current implementation:

app.ddview = ember.view.extend({ // ... didinsertelement: function (arg) { // logic var $this = this.$(); $this .draggable(/*...*/) .resizable(/*...*/); //delegate $(document).hammer().on("tap hold swipe", $this, function (e) { console.log(e.type) }); } // ... });

there 2 problems:

if bind events $this element, divs aren't draggable anymore (probably mousedown event default prevented). if delegate event (as shown in code), divs draggable, events fire on whole document.

if there placed more divs, events fired multiple.

so thought, smartest solution teach ember, there more events handle than

'click', 'doubleclick', 'contextmenu' ...

i'd implement event(handlers) shown below:

app.ddview = ember.view.extend({ tap: function(){}, hold: function(){}, pinch: function(){}, // ... });

if there much easier methods realize this, sense free post them. thanks

update:

changing selector "$this" "'#'+$this[0].id" solves problems, seems dirty solution.

$(document).hammer().on("tap hold swipe", '#'+$this[0].id, function (e) { ... });

so there's still question if it's possible teach ember new events.

it's not wanted, because have "workaround" in each view. now, solution works fine:

var hammerevents = ["touch", "release", "gesture", /* ... */]; didinsertelement: function (arg) { /* ... */ var emthis = this, $this = this.$(), touchevents = hammerevents.join(" "); $(document).hammer().on(touchevents, '#' + $this[0].id , function (e) { if (typeof emthis.get(e.type) == "function") { emthis.get(e.type).call(emthis); } }); }

jquery ember.js hammer.js

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -