Modal from a div?

I can get the modal iframe to work from an anchor tag in the body of the site, but how would I get it to work from inside a DIV?

Posted June 22nd, 2007 at 6:29am by danthe

The contents option can be a function which returns the contents, so you could do something like:

my_modal = new Control.Modal(false,{
    contents: function(){
        retrun $('my_div').innerHTML;
    }
});
$('some_link').observe('click',my_modal.open.bind(my_modal));

Posted June 22nd, 2007 at 9:26am by ryan

That's not ideal because if you have any HTML elements with ids inside 'my_div' then you are making invalid HTML. Is there a better way of doing this?

Posted June 27th, 2007 at 9:49am by duaneatat

Upon looking at the question again, maybe I mis-understand it. Another way to accomplish this is to create a modal from a link, store a reference to it, and then do something like:

$('other_element').observe('click',stored_modal.open.bind(stored_modal));

Posted June 27th, 2007 at 10:02am by ryan

Nice, that's what I'm looking for. One last question is, how do you make that initial reference without the modal opening when you instantiate the modal?

Posted June 27th, 2007 at 10:05am by duaneatat

Sorry, ignore my last question! Thanks for your help Ryan

Posted June 27th, 2007 at 10:08am by duaneatat

Login or Register to Post