javascript - Bind events in iframe content even when change url -
i'm trying bind envent when form submitted inside iframe, i'm having problems:
first attempt:
i tried bind envent when page loads, worked, event binded when page loads entirely.
$('#mainframe').on("load", function() { $('#mainframe').contents().find('form').submit(function(){ $('#overlay').addclass("overlay"); }); });
then tried use ready event
$('#mainframe').ready(function() { $('#mainframe').contents().find('form').submit(function(){ $('#overlay').addclass("overlay"); }); });
but isn't called when url changed.
second attempt:
i tried bind event on every input inside iframe, think can't access iframe elements without .contents()
$('#mainframe').on("click", 'input',function(){ $('#overlay').addclass("overlay"); });
ps: iframe page same domain
someone can me, please?
this should comment, not have karma. sorry spam.
if on load happens slow consider trigerring events inside iframe, maybe add code form submit:
window.parent.jquery(window.parent.document).trigger('iframestuff');
and in parent page listen it:
$(document).on('iframestuff', function(){ });
Comments
Post a Comment