[symfony-users] Re: How to pass PHP values to addJavascript() (or something else) ?

2010-06-25 Thread Tom Ptacnik
And what do you suggest if I need for example some texts... some info
messages .. assume that I'm using I18n. Is there another way than read
it from the DOM .. some hidden generated div, or span.. or whatever.



On 24 čvn, 18:19, Massimiliano Arione garak...@gmail.com wrote:
 On 24 Giu, 08:05, Tom Ptacnik to...@tomor.cz wrote:

  So if I need to get some variables in javascript from the app, you
  advice is to generate it into the DOM?

  Example: I need to detect which culture is set. Then i should generate
  div id=culture style=display:none;en/div into the DOM and then
  in the javascript read the value of the div by id?

 If you just need the culture, you should get it from html tag. (in the
 lang attribute)
 Of course, you should before set it in html tag, but it's trivial:
 just set it in layout.php

 cheers
 Massimiliano

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

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


Re: [symfony-users] Re: How to pass PHP values to addJavascript() (or something else) ?

2010-06-25 Thread Ben Bieker
On Thu, 24 Jun 2010 23:27:38 -0700 (PDT), Tom Ptacnik to...@tomor.cz
wrote:
 And what do you suggest if I need for example some texts... some info
 messages .. assume that I'm using I18n. Is there another way than read
 it from the DOM .. some hidden generated div, or span.. or whatever.
 

Hi,

maybe you could load them via an ajax call? Would be an elegant solution I
think.
You could write a litle web service especially for your javascript's needs
or so..

would be grat for i18n too because the language is set in php and your
webservice always delivers the correct language then.

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

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


[symfony-users] Re: How to pass PHP values to addJavascript() (or something else) ?

2010-06-25 Thread Tom Ptacnik
Ajax was in my mind too, but I don't like to create a request for the
recieving a translation text... If I need 5 info messages, there will
be 5 requests. It looks bad to me... slowing down the app
unnecessarily.


On 25 čvn, 10:55, Ben Bieker m...@ben-bieker.de wrote:
 On Thu, 24 Jun 2010 23:27:38 -0700 (PDT), Tom Ptacnik to...@tomor.cz
 wrote:

  And what do you suggest if I need for example some texts... some info
  messages .. assume that I'm using I18n. Is there another way than read
  it from the DOM .. some hidden generated div, or span.. or whatever.

 Hi,

 maybe you could load them via an ajax call? Would be an elegant solution I
 think.
 You could write a litle web service especially for your javascript's needs
 or so..

 would be grat for i18n too because the language is set in php and your
 webservice always delivers the correct language then.

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

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


[symfony-users] Re: How to pass PHP values to addJavascript() (or something else) ?

2010-06-24 Thread Tom Ptacnik
So if I need to get some variables in javascript from the app, you
advice is to generate it into the DOM?

Example: I need to detect which culture is set. Then i should generate
div id=culture style=display:none;en/div into the DOM and then
in the javascript read the value of the div by id?


On 23 čvn, 14:57, Massimiliano Arione garak...@gmail.com wrote:
 On 22 Giu, 10:03, François franc...@robichet.com wrote:

  I'd like to pass values to my JS script when I call it. So I look the
  API for the addJavascript() method, herre is it :

 You shouldn't pass variables from php to javascript.
 Javascript should be always unobtrusive, so the only point of contact
 between your html (and php) and your javascript should be the DOM.
 Just insert your php variables somewhere in your page (e.g. in a
 hidden field of a form), then retrieve them with javascript (with
 jQuery, it's really simple)

 cheers
 Massimiliano

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

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


[symfony-users] Re: How to pass PHP values to addJavascript() (or something else) ?

2010-06-24 Thread Svetoslav Shterev
That would be one way.

On Jun 24, 9:05 am, Tom Ptacnik to...@tomor.cz wrote:
 So if I need to get some variables in javascript from the app, you
 advice is to generate it into the DOM?

 Example: I need to detect which culture is set. Then i should generate
 div id=culture style=display:none;en/div into the DOM and then
 in the javascript read the value of the div by id?

 On 23 čvn, 14:57, Massimiliano Arione garak...@gmail.com wrote:

  On 22 Giu, 10:03, François franc...@robichet.com wrote:

   I'd like to pass values to my JS script when I call it. So I look the
   API for the addJavascript() method, herre is it :

  You shouldn't pass variables from php to javascript.
  Javascript should be always unobtrusive, so the only point of contact
  between your html (and php) and your javascript should be the DOM.
  Just insert your php variables somewhere in your page (e.g. in a
  hidden field of a form), then retrieve them with javascript (with
  jQuery, it's really simple)

  cheers
  Massimiliano

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

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


[symfony-users] Re: How to pass PHP values to addJavascript() (or something else) ?

2010-06-24 Thread Massimiliano Arione
On 24 Giu, 08:05, Tom Ptacnik to...@tomor.cz wrote:
 So if I need to get some variables in javascript from the app, you
 advice is to generate it into the DOM?

 Example: I need to detect which culture is set. Then i should generate
 div id=culture style=display:none;en/div into the DOM and then
 in the javascript read the value of the div by id?

If you just need the culture, you should get it from html tag. (in the
lang attribute)
Of course, you should before set it in html tag, but it's trivial:
just set it in layout.php

cheers
Massimiliano

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

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


[symfony-users] Re: How to pass PHP values to addJavascript() (or something else) ?

2010-06-23 Thread Massimiliano Arione
On 22 Giu, 10:03, François franc...@robichet.com wrote:
 I'd like to pass values to my JS script when I call it. So I look the
 API for the addJavascript() method, herre is it :

You shouldn't pass variables from php to javascript.
Javascript should be always unobtrusive, so the only point of contact
between your html (and php) and your javascript should be the DOM.
Just insert your php variables somewhere in your page (e.g. in a
hidden field of a form), then retrieve them with javascript (with
jQuery, it's really simple)

cheers
Massimiliano

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

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