I could do that but in my case, the images names must be dynamic so
the problem would be the same.

On Nov 23, 6:36 pm, Miles J <mileswjohn...@gmail.com> wrote:
> Instead of pre-loading images, just use css rollovers.
>
> On Nov 23, 9:20 am, thomaus <tho...@saimiris.com> wrote:
>
> > Thanks for your answer.
>
> > I tried by putting the javascript inside the PHP script and it works
> > fine, thanks.
>
> > Nevertheless, I would like to know how to do that by using an external
> > javascript. The solution you propose is fine as long as you call the
> > function somewhere but in my case, I just call include the JS in the
> > header page and never call the function in itself. So my question is :
> > is there a way to pass variables form PHP to JS the same way the
> > controller set variables to be used by the view this way $this->set
> > ('lang_menu', $lang_menu);
> > Something like $js->set('lang_menu', $lang_menu); would be nice but
> > does it exist???
>
> > Thanks,
>
> > On Nov 23, 4:41 pm, Dave <davidcr...@gmail.com> wrote:
>
> > > If you have the javascript in your php file you can interject php syntax
> > > just like html
>
> > > ie. $.preloadImages("<?php echo $image_src; ?>", "img/
>
> > > if your javascript is in a separate .js file you have two options
>
> > > 1. Change the javascript function to allow you to specify anything dynamic
> > > (ie. the images that will need to be preloaded) in a parameter which you 
> > > can
> > > pass from your php file when you call the function using the method above
>
> > > or
>
> > > 2. (Not Recommended) Set up your web server to run .js files through the 
> > > PHP
> > > parser.  Then you can use php syntax in the .js files
>
> > > On Mon, Nov 23, 2009 at 6:31 AM, thomaus <thomas.ausse...@gmail.com> 
> > > wrote:
> > > > Hi there,
>
> > > > I've been using CakePHP since 6 months and never had a single problem
> > > > BUT now I have one issue I can't solve. Here it is:
>
> > > > I need to Preload some images for my website. I did it using JQuery
> > > > and it perfectly works:
>
> > > > CODE
> > > > $(document).ready(function(){
>
> > > > // Preload
> > > > $.preloadImages("img/button_home_en_over.gif", "img/
> > > > button_portfolio_en_over.gif", "img/button_about_en_over.gif", "img/
> > > > button_contact_en_over.gif",
> > > > "img/button_portfolio_en_select_over.gif", "img/
> > > > button_about_en_select_over.gif", "img/
> > > > button_contact_en_select_over.gif",
> > > > "img/button_home_es_over.gif", "img/button_portfolio_es_over.gif",
> > > > "img/button_about_es_over.gif", "img/button_contact_es_over.gif",
> > > > "img/button_portfolio_es_select_over.gif", "img/
> > > > button_about_es_select_over.gif", "img/
> > > > button_contact_es_select_over.gif",
> > > > "img/button_home_ca_over.gif", "img/button_portfolio_ca_over.gif",
> > > > "img/button_about_ca_over.gif", "img/button_contact_ca_over.gif",
> > > > "img/button_portfolio_ca_select_over.gif", "img/
> > > > button_about_ca_select_over.gif", "img/
> > > > button_contact_ca_select_over.gif",
> > > > "img/button_home_fr_over.gif", "img/button_portfolio_fr_over.gif",
> > > > "img/button_about_fr_over.gif", "img/button_contact_fr_over.gif",
> > > > "img/button_portfolio_fr_select_over.gif", "img/
> > > > button_about_fr_select_over.gif", "img/
> > > > button_contact_fr_select_over.gif"
> > > > );
>
> > > > // hover
> > > > $("#menu_buttons a img").hover(function() {
> > > >    $(this).attr("src", $(this).attr("src").split(".").join
> > > > ("_over."));
> > > >  }, function() {
> > > >    $(this).attr("src", $(this).attr("src").split("_over.").join
> > > > ("."));
> > > >  });
> > > > });
>
> > > > // Preload function
> > > > jQuery.preloadImages = function()
> > > > {
> > > > for(var i = 0; i<arguments.length; i++)
> > > > {
> > > >  //alert(arguments[i]);
> > > >  jQuery("<img>").attr("src", arguments[i]);
> > > > }
> > > > }
>
> > > > Now I would like to preload some of the images and not all of them
> > > > cause 1) it's taking ages 2) I just need some them depending of the
> > > > language I use. But in order to do so, I should be able to access some
> > > > PHP variables from my JQuery script.
>
> > > > So my question is: is there a way in CakePHP to pass variables to
> > > > Javascript / JQuery???
>
> > > > Thanks in advance.
>
> > > > --
>
> > > > You received this message because you are subscribed to the Google 
> > > > Groups
> > > > "CakePHP" group.
> > > > To post to this group, send email to cake-...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > cake-php+unsubscr...@googlegroups.com<cake-php%2bunsubscr...@googlegroups.com>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/cake-php?hl=.

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.


Reply via email to