jqModal/JQuery problem, div not updating with new content?
- by echoesofspring
I'm hoping someone can point a relative jQuery/jqModal newbie in the right direction for debugging this error. I'm loading an html fragment into a div and then use jqModal to display that div as a modal dialog. The problem is that the div is displayed but not with my updated html.
I'm showing my jqModal dialog in the response from a jquery call, function foo is called from an onclick event:
function foo(url)
{
$.ajax({
type: "GET",
url: url,
success: function(msg)
{
$('#ajaxmodal').html(msg);
$('#ajaxmodal').jqmShow();
}
});
}
ajaxmodal is a simple div.
Initially I thought the problem must be in the html snippet (msg) I'm passing to the callback, but I don't think that's it, I get the err (see below) even when I comment out the $('#ajaxmodal').html(msg) line or pass it hardcode html. I think I have jqModal configured correctly, other calls using our ajaxmodal div work correctly, I'm able to display the modal, update the content based the server response, etc.
When I try to debug in firebug, I get the following error following the call to .jqmShow(). I have seen the err on occasion in other places when it seemed maybe the page hadn't loaded yet, and I confess I'm confused about that, since we've wrapped our jqModal selectors in a $(document).ready() call, so maybe I have a larger issue that this call just happens to trigger?
From the jquery.jqModal.js file, line 64: js err is $(':input:visible',h.w)[0] is undefined in the line:
f=function(h){try{$(':input:visible',h.w)[0].focus();}catch(_){}}
When I step through this in firefox, h.w[0] seems ok, it references our '#ajaxmodal' div.
Thanks in advance for any suggestions in tracking this down?