samedi 20 août 2016

How to insert javascript var into path on Twig?

I want to insert a var declared in javascript into my path to redirect my page.

My code is:

 var id = $(this).attr('data-id');
 windows.location = {{ path("mylink", {id: id}) }};

But I can't know how can insert my var id into path, because when I try this I get error, I'm trying to parse this with +' myvar '+ so concatenating text but I can't.

How can I concatenate or add my var into path?

Thanks!

Aucun commentaire:

Enregistrer un commentaire