jQuery Asual address keeps appending sites root folder

拜拜、爱过 提交于 2019-12-11 05:19:44

问题


I have an MVC site located in several subfolders on a site for dev & stage:

  • www.domain.com/site_dev/
  • www.domain.com/site_stage/

It will eventually end up at the root of the site in production, but when testing my site in the subfolders jquery address appends the subfolder in the deep-linking like so:

  • www.domain.com/site_dev#!/site_dev/home/about

I'm using ajax to load panels dynamically using the values in the deep linking, but my panels won't load because it's trying to call the controller /site_dev/home/about which does not exist.

How can I get it to not do this? I would like it to simply use:

  • www.domain.com/site_dev#!/home/about

I don't want to hard code the values anywhere so it needs to be dynamic. I've searched all over, but maybe I'm not using the right keywords for what I'm looking to do. Any help is appreciated.


回答1:


I had a similar problem. The problem is caused that jquery address thinks that www.domain.com/site_dev/ is the root instead of www.domain.com. This will cause all url's to be loaded after www.domain.com/site_dev#!/ You need to fix in the init() of the plugin. Simply do

$.address.state('/').init(function(event)

Probably you had something similar to (this was my case):

$.address.state($.address.baseURL()).init(function(event)

or

$.address.state('www.domain.com/site_dev').init(function(event)



来源:https://stackoverflow.com/questions/11256638/jquery-asual-address-keeps-appending-sites-root-folder

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