Skip to content

Commit fad8e7f

Browse files
committed
made tabs work with backbone.js style URLs like example.com/myapp#users/pg/3
1 parent fc1115e commit fad8e7f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/tabs/tabs.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,15 +275,21 @@
275275
self.click($(this).attr("href"), e);
276276
});
277277

278+
// Use only the part of location.hash that is in front of the first
279+
// slash. This is for frameworks like Backbone.js where you might have
280+
// a URL like http://example.com/myapp#users/pg/3
281+
var slashIndex = location.hash.indexOf("/"),
282+
locationHashStr = slashIndex === -1 ? location.hash : location.hash.slice(0, slashIndex);
283+
278284
// open initial tab
279-
if (location.hash && conf.tabs == "a" && root.find("[href=" +location.hash+ "]").length) {
280-
self.click(location.hash);
285+
if (locationHashStr && conf.tabs == "a" && root.find("[href=" + locationHashStr + "]").length) {
286+
self.click(locationHashStr);
281287

282288
} else {
283289
if (conf.initialIndex === 0 || conf.initialIndex > 0) {
284290
self.click(conf.initialIndex);
285291
}
286-
}
292+
}
287293

288294
}
289295

0 commit comments

Comments
 (0)