FOSJsRoutingBundle dont recognize route

限于喜欢 提交于 2019-12-05 09:31:48
Mick

Your code is great.

I suggest that you open an issue here, this is very likely to be a bug as you're not the only one to have that issue.

It's probably easier than you think. Visit the page generated here: {{ path('fos_js_routing_js', {"callback": "fos.Router.setData"}) }} it should have json-encoded list of your exposed routes. If your route is there you're good.

How check when you execute console.log(Routing.generate('usuarios_crear')); The document should be ready before you try that. So make sure it is (i.e. jQuery's $('document').ready()).

Reading the Github issues, found this where the author suggest not use the dev-master version. I do a downgrade to "@stable", and works (for now). The composer.json line may be:

"friendsofsymfony/jsrouting-bundle": "@stable"

For more detail: The full install guide.

Don't require dev-master in a composer.json file, never ever, ever! It is a bad practice.

Rely on stable releases please: https://github.com/FriendsOfSymfony/FOSJsRoutingBundle/releases

I just had the same issue, and the solution was include the ^/js/* route to access anonymously in your security configuration.

I hope it helps!

Try to use this code Suppose you have the an onclick function that receives an id when clicked so your js code will something like this

function show(id)
{

    var url = '{{ path('usuarios_crear',{ id: 'id' }, {"callback": "fos.Router.setData"}) }}';
    url = url.replace("id", id);
    window.location.href = url;

} 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!