ajax modal

i'm struggling trying to get an ajax modal window to show up- this comes from the api doc

function showPopup(url,width,height){ var myModal = new Control.Modal(false, { contents: function(){ new Ajax.Request(url,{ onSuccess: function(request){ this.update(request.responseText); } .bind(this)}) }, loading : true, iframe : true, overlayCloseOnClick : false });

myModal.open();  

}

the error i get is "html has no properties" on this line:

(html.each) ? html.each(function(node){

anybody have an example of a simple ajax modal not attached to an href?

Posted September 18th, 2007 at 8:47pm by doofus

Hi,

Can you post a link or some more code to the context in which you're using html.each?

That code really doesn't sound right, and probably needs to be re-written. Use the JS code formatting button in the toolbar to get your code to appear correctly in the comment.

Ben

Posted September 19th, 2007 at 6:32am by bbodien

i'm not using html.each, that line came from the update() function in the js file- here is my formatted code

function showPopup(url,width,height){ 
var myModal = new Control.Modal(false, 
{ contents: function(){ new Ajax.Request(url,{ onSuccess: function(request){ this.update(request.responseText); } .bind(this)}) }, loading : true, iframe : true, overlayCloseOnClick : false });
myModal.open();  
} 

Posted September 19th, 2007 at 5:56pm by doofus

and there really is no other code to show, just a button doing something like onclick="showPopup('blank.htm')"

it appears as though the content is getting evaluated before the ajax response ever comes back, because the error is instant- and i see it takes a second or two for the response to be made in firebug.

Posted September 19th, 2007 at 6:01pm by doofus

It looks like you're missing a semicolon - I'm not sure if that's the problem but it could be messing things up.

Try this:


function showPopup(url,width,height) {   
  var myModal = new Control.Modal(false, { 
    contents: function() { 
      new Ajax.Request(url, { 
        onSuccess: function(request) { 
          this.update(request.responseText);
        }.bind(this)
      });
    },
    loading : true, 
    iframe : true, 
    overlayCloseOnClick : false 
  });  
  myModal.open();    
}

If that's still not working, can you put the page online so I can debug it in Firebug?

Ben

Posted September 20th, 2007 at 3:50am by bbodien

Login or Register to Post