Control.Modal using class vs. id
or, now that I have figured out how to get all the links generated by the search (AJAX call) using:
$(div_name).getElementsByClassName(class_name).each( function(s) { }
is there a way to attach the Event.Observe( new Control.Modal() } commands to each link in the onSuccess event of the AJAX call ??
Posted April 2nd, 2007 at 11:08pm by httpdotcom
Something along these lines?
new Ajax.Request(some_url,{ onComplete: function(request){ $(some_element).update(request.responseText); $$('div .some_class_name').each(function(link){ link.modal = new Control.Modal(link.href); link.observe('click',function(){ this.modal.open(); }); }); } });
Posted April 2nd, 2007 at 11:21pm by ryan
I'm going to have to figure out a way to get the spacing to be better in the forum for the code, sorry - Ryan
Posted April 2nd, 2007 at 11:21pm by ryan
This triggered an idea. I added a "contents" option that lets you manually specify the contents of a modal. You don't need a link object if you do this, you can create a pure javascript modal.
Posted April 3rd, 2007 at 12:00am by ryan
I am assuming that this has been rolled into the download, and that maybe you could provide some example code? Thanks!
Posted April 3rd, 2007 at 10:29am by httpdotcom
There is an added blurb on the control.modal page. If you know JS then it should be pretty easy with that and the example above, but unfortunately I don't have time to teach the finer points of scripting.
Posted April 3rd, 2007 at 1:33pm by ryan
The blurb was sufficient to get a "working" javascript-based modal. Thanks for the update!
Posted April 3rd, 2007 at 5:26pm by httpdotcom
I have a search engine that produces results in batches of 1..25.
Is it possible (with rewrites to the JS file if necessary) to use a "modal" class for all the links to "lightbox" into, rather than assigning each link a separate id (modal1, modal2...) and creating the appropriate Event.Observe statements?
Posted April 2nd, 2007 at 10:14pm by httpdotcom