Reputation: 1250
Basically I have a bundle in Symfony with routing.yml
:
main_move:
pattern: /move/{direction}
defaults: { _controller: MainBundle:Move:move }
And javascript
file
$(".left_button").click(function(){
$.ajax({
url: '/move/1'
}).done(function(){
$(".button").css("width","1000px");
});
});
Can I only put full path to that bundle or it can be like in twig: {{ path(main_move)}}
(I have already tried that one)
Upvotes: 0
Views: 69
Reputation: 1250
Ok I did it like:
$(".move_button").click(function(){
var path = $(this).attr("data-path");
$.ajax({
url: path
}).done(function(){
$(".button").hide();
});
});
And in twig:
data-path="{{ path('main_move', { 'direction': 1 }) }}"
Upvotes: 1
Reputation: 1085
Use JSRoutingBundle for this: https://github.com/FriendsOfSymfony/FOSJsRoutingBundle
Upvotes: 2