Note that there are some explanatory texts on larger screens.

plurals
  1. POdrop event not firing on backbone view
    primarykey
    data
    text
    <p>I was happily coding and learning backbone when this #~@@! happened!</p> <p>I use require to separate my views from models, etc.</p> <p>In my Backbone view I handle this events:</p> <pre><code>define(['...'],function(...) { var DishView = Backbone.View.extend({ template: _.template(dish), tagName: 'div', id: 'dish', initialize: function() { console.log('initializing dishView'); this.model.on('change', this.render, this); }, render: function(){ console.log('rendering dishView'); this.$el.html(this.template(this.model.toJSON())); return this; }, events: { 'click #relations-menu .newItem': 'launch_modal_relations', 'click #delete' : 'delete_dish', 'click #save-basic-changes': 'save_basic', 'drop #dropPicture' : 'dropHandler', 'dragenter #dropPicture' : 'alertMe' }, alertMe: function () { console.log('clicked on image'); }, delete_dish: function () { this.model.deleteMyself(); Backbone.history.navigate('/', {trigger: true}); }, save_basic: function (event) { var name = $('#inputName').val(); var description = $('#inputDescription').val(); var price = $('#inputPrice').val(); this.model.updateBasicInfo(name, description, price); }, dropHandler: function(event) { event.preventDefault(); console.log('drop received'); event.stopPropagation(); var e = event.originalEvent; e.dataTransfer.dropEffect = 'copy'; this.pictureFile = e.dataTransfer.files[0]; ... }, return DishView; }); </code></pre> <p>My drag&amp;drop was working and suddenly when a lot of more functionality was added, it stopped working :( the image file it's opened in the browser.</p> <p>I've read about the DOM being ready and that this can happen sometimes (if the code gets evaluated when the DOM is ready) <strong>but the click events still get fired, also the dragenter event....</strong></p> <p>Could this be some typo?? I'm going a little bit crazy I can't understand whats going on and can't remember a good commit to go back and check :S</p> <p>Thank you all if you can show some possible answers :) </p> <p>For example: - how can I debug the drop event??? - how can I know if an event is tied to my view?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload