javascript - jQuery UI Dialog IE8 problem -


i have jquery ui dialog contains form, allowing user post ad. since form contains file upload, form's target iframe.

from iframe, destroy dialog in parent window , create new 1 (or change options of original dialog, doesn't make difference). point iframe, define new buttons new dialog attached events work on main window elements.

in firefox, safari, chrome works well:

var p = parent;      p.$('#dialog_new_ad').html('<form id="post_ad_form" style="display: none" data-remote="true"></form><div class="header"><h1 class="header_title"></h1><div class="header_company"></div><div class="header_location"></div></div><div class="content"></div>');  p.$('#dialog_new_ad').dialog({  minheight: 600,  width: 800,  position: ['center',25],  modal: true,  autoopen: false,  title: '<%= 'preview: ' if params[:action] == 'preview' %><%= @ad.title %>',  buttons: {   "« back": function() {    p.$('#post_ad_form').attr('method','get');    p.$('#post_ad_form').attr('action','/ads/<%= @ad.id %>/revise');    p.$('#post_ad_form').submit();   },   "submit »": function() {    p.$('#post_ad_form').attr('method','post');    p.$('#post_ad_form').html('<input type="hidden" name="_method" value="put">');    p.$('#post_ad_form').attr('action',"/ads/<%= @ad.id %>/confirm");    p.$('#post_ad_form').submit();   }  } }); 

this code in iframe form posts to.

if @ button functions, you'll see doing defined in context of child window (iframe), though buttons in parent window. it's because function created in iframe, , objects must referenced context.

now problem in internet explorer works sometimes, not others. when doesn't, error "can't execute code in freed script" , points part of jquery-ui.js button functions defined. whether or not error occurs random. if depends on whether or not has finished before code called. mentioned, in other browser works.

the entire thing (in iframe) enclosed in $(function() { [...] } , dom loaded that's not issue. might have fact form created .html call not "finished being put dom" when button functions defined, seem strange me. ideas?

note: jquery .html function uses innerhtml create new elements. possible leads problems in ie, if elements referenced directly thereafter?

update: gave , put dummy form in parent element, can used children iframes of different kinds, whether or not loaded. when form static part of parent html , not dynamically inserted, works fine. still don't understand why dynamic insertion doesn't work in ie though.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -