简体   繁体   中英

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.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM