Search code examples
javascriptjquerybackbone.jsbackbone-views

How can I add events for elements inside an iframe from the parent document with Backbone.js


I have an iframe for which I need to bind a click Backbone View Event to some of its DOM elements.

I tried with something like this, but it doesn't event make any sense:

 el: $('#app'),
 events:{
   'click #iframe .button1': 'clickEvent'
 }

Do you guys know how to do that?

Thank you.


Solution

  • It's not possible using events property. If you have an access to the iframe you can do it manually, like this:

    this.$('#iframe').contents().find('.button1').on('click', this.clickEvent)