sammy.js

Cancel route using Sammy.js without affecting history

浪子不回头ぞ 提交于 2020-01-22 18:15:33
问题 I want to intercept all route changes with Sammy to first check if there is a pending action. I have done this using the sammy.before API and I return false to cancel the route. This keeps the user on the 'page' but it still changes the hash in the browsers address bar and adds the route to the browsers' history. If I cancel the route, I dont want it in the address bar nor history, but instead I expect the address to stay the same. Currently, to get around this I can either call window

sammyjs optional parameters

馋奶兔 提交于 2020-01-21 03:25:14
问题 Just wondering if there is anyway to specify a parameter as optional in a sammy js route. I've seen somewhere that you can use route/:foo/?:bar and that will trick sammy into thinking that bar is optional. However if you query your params without bar supplied you that it will equal the last character of the url for example '#/route/test' => {foo: 'test', bar: 't'} and '/route/test/chicken' => {foo: 'test', bar: 'chicken' } but with bar getting populated in both cases there is no way to check

Twitter bootstrap accordion not working with Sammy.js

流过昼夜 提交于 2020-01-15 18:47:02
问题 I am trying to use twitter accordion in single page app but it has conflict with sammy.js <a class="ac-toggle" data-toggle="collapse" data-parent="#ac2" href="#collapseOne">Company</a> When I try to collapse it change the url. I have ignore the route in sammy.js but it did not work. Is there other method of this using jquery or ignore the route in sammy.js ? this.get(/\#collapse(.*)/, function (cx, match) { ???? }); 来源: https://stackoverflow.com/questions/14284022/twitter-bootstrap-accordion

How to Handle Page Reloads

北慕城南 提交于 2019-12-24 20:11:44
问题 As I understand it the "conventional" way to handle page reloads is to duplicate functionality and presentation on the web stack using its controllers, views, and models. I'd appreciate insight on other (possibly better) ways to handle these situations. As well as feedback on the following two approaches: Reload the js framework based app/suite on every web (stack) app page thus forcing the js framework to handle all routing and rendering Use the web stack to route interactions and then use

Deep-linking with Sammy.js?

一曲冷凌霜 提交于 2019-12-24 10:41:08
问题 I recently built a website using the sammy.js framework. The site includes a portfolio page with a grid of thumbnails that link to the detail page for each portfolio piece. All of this works. What I cannot seem to figure out how to do is be able to provide someone a link to a specific project on the site (ex: www.thesite.com/#/work-detail/some-project) and have it run the work-detail route with "some-project" as the variable that gets passed for it to load the correct content. Any help would

multiple knockout bindings and sharing them

浪尽此生 提交于 2019-12-24 07:14:38
问题 So I have a scenario where I am have knockout binding on my main page. Index.cshtml: <div data-bind="foreach breadcrumbs"> <div> <script> var IndexViewModel = function () { var self = this; self.breadcrumbs = ko.observableArray(); }; ko.applyBindings(IndexViewModel); </script> And a Partial View that loads inside the Index.cshtml. The partial view has its own knockout bindings: <div id="someId"> </div> <script> var PartialViewModel = function () { var self = this; self.someFunction = function

How to redirect from pages without trailing slashes to pages with trailing slashes

纵饮孤独 提交于 2019-12-24 05:03:28
问题 I have sammy.js running in a knockout.js app. I'm currently trying to redirect routes that are missing the trailing slash (for example /#/stop/1/100032 ) I would like to redirect all such pages missing the trailing slash, to the page with the trailing slash. To complicate things, I would also like to have an error page in the case that there is no such route. function RoutesViewModel () { var self = this; self.router = Sammy(function () { this.get('/#/stop/:agency_id/:stop_id/', function () {

Sammy routing not working

◇◆丶佛笑我妖孽 提交于 2019-12-23 11:00:41
问题 I'm unable to get sammy.js routing working as expected. I have the following JavaScript. (function ($) { var app = $.sammy('#main', function () { this.get('#/', function (context) { context.log("start page"); }); this.get("#/another/:id/", function (context) { context.log("another page with id = " + context.params["id"]); }); }); $(function (context) { app.run('#/'); }); })(jQuery); My understanding is that whenever the URL has changes, and so long as the new route corresponds to one of the

Sammy.js 404 on root path

笑着哭i 提交于 2019-12-23 07:41:41
问题 I'm trying to define some routes with sammy.js here is my code: $.sammy("#main_content", function() { this.get("#!/about", function() { // Code }); this.get("#!/", function() { // Code }); }).run(); If I goto www.mywebsite.com I always get a 404 error. I've tried putting a blank route in like this.get("", function() {}); and that seems to work for preventing the 404 error but then none of my normal links on the page work. How do I go about fixing this? 回答1: Just override not found: this

Sammy.js app link routing not working in phonegap

邮差的信 提交于 2019-12-23 05:22:41
问题 I am trying to get a basic sammy.js app running through phonegap. The app loads fine but when running the app through my android (2.2) handset the routing doesn't seem to work- nothing happens when the links are clicked, but when running the app through an Android virtual device (2.1) the links work as expected and the correct templates are rendered. Has anyone encountered this problem or similar who might be able to point me in the right direction as there is limited documentation regarding