Skip to content

Instantly share code, notes, and snippets.

@hustKiwi
Created June 15, 2012 10:23
Show Gist options
  • Select an option

  • Save hustKiwi/2935751 to your computer and use it in GitHub Desktop.

Select an option

Save hustKiwi/2935751 to your computer and use it in GitHub Desktop.
// 没有依赖Backbone的History机制,而是调用Native命令实现页面切换,
// 由Native来统一管理History。
$(document).on('click', 'a, .url', function(e) {
e.preventDefault();
var pattern = /#!(.+)/,
$this = $(this),
href = $this.attr('href') || $.this.data('url');
if (href && href.match(pattern)) {
Crab.createView({ action: href });
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment