window.addEvent does not work in squeezebox

a place to get help

Moderator: 1.1 Moderators

window.addEvent does not work in squeezebox

Postby Anneminchen on Fri Feb 19, 2010 12:33 pm

hello,

i am working on a simple joomla website using the mootools 1.1 library. on my site i have link to onclick load a view (php file) into a lightbox-like modal window. the loaded document has a window.addEvent('domready', function(){}) declaration inside to attach a click-event on an image which shall pop a little alert window up. for any reason this doesn't work when the window has been loaded in the overlay box. but if i open the php file directly all works fine. i don't unterstand the problem and especially why firebug is not responding with any errors.

can u guys help me please?
Anneminchen
 
Posts: 4
Joined: Fri Feb 19, 2010 12:07 pm

Re: window.addEvent does not work in squeezebox

Postby daKmoR on Fri Feb 19, 2010 1:27 pm

Anneminchen wrote:when the window has been loaded in the overlay box


how do you load the window inside the overlay?
"Speak when you are angry and you will make the best speech you will ever regret." - Ambrose Bierce
User avatar
daKmoR
Site Admin
 
Posts: 860
Joined: Mon Jul 14, 2008 11:40 am

Re: window.addEvent does not work in squeezebox

Postby Anneminchen on Fri Feb 19, 2010 3:07 pm

hi, i add the "modal" class attribute to the link and activate the "behaviour" in the index.php using the command
  1. JHTML::_('behavior.modal');
this initialized the framework to write this command to the document
  1.  
  2. window.addEvent('domready', function() {
  3.    SqueezeBox.initialize({});
  4.    $$('a.modal').each(function(el) {
  5.       el.addEvent('click', function(e) {
  6.          new Event(e).stop();
  7.          SqueezeBox.fromElement(el);
  8.       });
  9.    });
  10. });
  11.  

you can find the site here. if you click the link, the overlay window is getting loaded. showing a graphic. this has got to be added the click-event. but no js is working in this case. if you go back to the entry site and do a "open in new tab/page" on the link then the targeted site is opened in normal way an all works properly.

as it seems the mootools lib does not take care of modal loded sites including scripts. may this be the case? how to handle it?

regard, anne
Anneminchen
 
Posts: 4
Joined: Fri Feb 19, 2010 12:07 pm

Re: window.addEvent does not work in squeezebox

Postby daKmoR on Fri Feb 19, 2010 4:41 pm

normally ajax should only return the needed parts (or at least only the body) and not the full head and stuff...

ajax requests usually don't execute javascript in the response text... however you can set it to do it anyway with
"evalScripts: true" if you look at
http://docs111.mootools.net/Remote/Ajax.js

now you will have to set it for the ajax request of SqueezBox as you don't create the ajax request manually...

let's see at the source code of SqueezeBox... yeah this should do it
  1. SqueezeBox.initialize({
  2.     ajaxOptions: {
  3.         evalScripts: true
  4.     }
  5. });
"Speak when you are angry and you will make the best speech you will ever regret." - Ambrose Bierce
User avatar
daKmoR
Site Admin
 
Posts: 860
Joined: Mon Jul 14, 2008 11:40 am

Re: window.addEvent does not work in squeezebox

Postby Anneminchen on Fri Feb 19, 2010 5:07 pm

but i don't do any ajax request on that site. i used this argument to show you that some eval procedure is missing like with the ajax requests. indeed i plan to do some. but as along as the simple alert() does not work i don't start coding any ajax stuff. the thing is, the Squeezebox.init() function is initialized by the joomla framework - so i don't touch the library as it will be overwritten with the next update. and for now i only like the simple alert() function to work when triggered from the window inside squeezebox. if this works properly then ajax will be the next step. btw. the loaded page is no complete page. it is some kind of include. so there is no head and footer stuff. only the output generated by some php functions.

did you check and test my site? what u think is the reason for the js not working?
Anneminchen
 
Posts: 4
Joined: Fri Feb 19, 2010 12:07 pm

Re: window.addEvent does not work in squeezebox

Postby daKmoR on Fri Feb 19, 2010 5:54 pm

oh boy...

of course you are doing an ajax request! how else should the content come inside the box?

the request is done by Squeezbox as it needs to get the content from the link somehow...
it's not an iframe it's ajax...
Attachments
request.PNG
ajax request
"Speak when you are angry and you will make the best speech you will ever regret." - Ambrose Bierce
User avatar
daKmoR
Site Admin
 
Posts: 860
Joined: Mon Jul 14, 2008 11:40 am

Re: window.addEvent does not work in squeezebox

Postby Anneminchen on Fri Feb 19, 2010 6:12 pm

i did not know this since i did neither program joomla nor the squeezebox. and there is no way of getting things managed without hacking the core?

btw... i'm a girl...
Anneminchen
 
Posts: 4
Joined: Fri Feb 19, 2010 12:07 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 3 guests