Control.Modal if JS is disabled

I searched for the past half hour through the Tutorial and API but couldn't solve my problem, so I figured I'd post about it.

I have several links throughout my site that need to open the same modal window. I have created a page (modal.htm) for my modal, and am including it on every page. Everything is working swimmingly. However, if someone does not have javascript enabled, the link won't work. I'd rather have the link take them to modal.htm, but when I put modal.htm as the HREF, the links go there instead of opening the modal.

Currently, my JS looks like this:

$$('a.Modal').each(function(element) 
    {
        element.observe('click', function(event)
        {
            Control.Modal.open($('modalWindow').innerHTML,
            {
                containerClassName: 'modalWindow',
                overlayClassName: 'overlay',
                overlayCloseOnClick: false,
                width: 284
            });
        });
    });

so that every link with a class of Modal opens the modal window.

Please help!

Posted November 13th, 2007 at 3:43pm by craig_willard

u could put the link to modal.htm in href and inside some javascript clear href param so it would work for javascript enabled and disabled

thats just some idea

im lazy so will not post code

Posted November 14th, 2007 at 1:49am by wk

<a href="modal.htm" class="Modal">Link</a>
element.observe('click', function(event){
    event.stop(); //	

Posted November 14th, 2007 at 12:02pm by Roland

ok wtf happened there?

element.observe('click', function(event){  
    event.stop(); // stop the default action
    Control.Modal.open(); // do your thing
});

Posted November 14th, 2007 at 12:04pm by Roland

use event.stop() on prototype 1.6 otherwise Event.stop(event);

Posted November 14th, 2007 at 12:05pm by Roland

Login or Register to Post