Backbone Router Ignoring search route

南楼画角 提交于 2019-12-08 07:20:56

问题


In need of some help!

I'm trying to get my Backbone router to match this route: http://localhost:5150/search_results?utf8=%E2%9C%93&keywords=&location=Norfolk%2C+VA&commit=Search

..And nothing is working. Very frustrating!
This is my first try at Backbone, so advice would be awesome.

 '/search_results?*': 'search_results'
  # NOPE

 '/search_results?foo=:foo': 'search_results'
  # NOPE

 '/search_results?foo*': 'search_results'
  # NOPE

 '/search_results?*queryString': 'search_results'
  # NOPE

 'search_results?*queryString': 'search_results'
  # NOPE

 'search_results?*': 'search_results'
 # NOPE

 'search_results?foo=:foo': 'search_results'
 # NOPE

 'search_results?foo*': 'search_results'
 # NOPE

'/search_results': 'search_results'
 # NOPE SERIOUSLY??

 '/search_results': 'search_results'
 # WTF!!!!!!!!!!!!!!!!!!!

 ':search_results?*': 'search_results'
 # NOPE

 ':search_results?:querystring': 'search_results'
 # NOPE

回答1:


Have you tried this? It should work without a leading colon, hash or slash in the route.

'search_results(?:queryString)': 'search_results'



回答2:


Okey... Backbone routes generally detect route path by # keyword as far as I know..correct me if I'm wrong. So to make the things work in your case do the following things.

1) Put the # keyword like #/search_results?....

2) Now define your route as "search_results?:queryString"

This should work :)



来源:https://stackoverflow.com/questions/15254230/backbone-router-ignoring-search-route

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