开发者

How to customize /#/ in Jquery address plugin

I'm using the Jquery plugin Address to achieve deep linking.

The generated urls come out in the format www.example.com/#/tab/image, but what I need is www.example.com/#tab/image. The plugin seems to automatically generate the /#/ part.

I wonder does anyone know how to do this? Or even if it's possible?

开发者_StackOverflow社区

I would greatly appreciate any help.

Thanks in advance


There is a plugin setting called "strict mode" that enforces the additional slash that you want to remove. You can do it in two ways:

  1. Include the script with an additional parameter:

  2. Call an API method

    $.address.strict(false);


Looking at the documentation, I looks like you can do this:

$('a').address(function() {  
     return $(this).attr('href').replace(/#\//, '#');  
});

This will replace #/ with #.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜