Tuesday 15 June 2010

symfony - How to use link generator from javascript variable ,in symfony2 -


I am trying to use link generator with javascript function.

  {% key to% value%} & lt; A href = "#" onClick = "bookConfirm ('{key}}'); returned;" & Gt; Click !! "And {/ a>} {% Endfor%} function book configure (key) {if (confirm (" is this OK? ")) {Warning (" OK !! "); Location.href =" {{ Path ('acme_member_bookLesson', {'scheKey': key}}}} ";} and {warning (" cancel! ");}}   

but it shows

"variable" key "does not exist in the extemal bundle: default: show.html.twig at line 19 '

How can I solve this problem? It is a bit complicated to use javascript and link generator.

Edit: second key is not in the loop, it means that This will always be the value of the last loop. You output the value of the key as the argument of the javascript function. The second key value is not the main value of the javascript function, but why is the key value in the toggle and how it can be fixed in my original answer:

Twig is a template engine that is written in PHP. This means that it runs on server side and outputs text to code. Then the code is sent to the browser and the browser purses and renders / executes html, css and javascript code.

So it is not possible to execute some twitter codes with javascript.

However, you can just use it to fix your code. This bundle does exactly what it says, it can handle most simphone routing features on client-side in javascript.

Your code will be something like this:

  Function Book Confirmation (Key) {If (Confirm ("Is this OK?")) {Warning ("OK is !!"); Location.href = routing. Generate ('acme_member_bookLesson', {key: key}); } And {warnings ("cancel!"); }}   

Read more about this

No comments:

Post a Comment