jQuery的Asual地址不断添加网站根文件夹 [英] jQuery Asual address keeps appending sites root folder

查看:101
本文介绍了jQuery的Asual地址不断添加网站根文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MVC网站位于开发人员网站上的几个子文件夹中.阶段:

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/

它最终将最终出现在生产站点的根目录中,但是当在子文件夹中测试我的站点时,jquery地址会将子文件夹追加到深度链接中,如下所示:

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

我正在使用ajax通过深度链接中的值动态加载面板,但是我的面板无法加载,因为它试图调用控制器/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.

推荐答案

我遇到了类似的问题.该问题是由于jquery地址认为www.domain.com/site_dev/是根目录而不是www.domain.com引起的.这将导致在www.domain.com/site_dev#!/之后加载所有url.您需要在插件的init()中进行修复.只需

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)

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

这篇关于jQuery的Asual地址不断添加网站根文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆