sammy.js

Sammy.js read route with &,?

自古美人都是妖i 提交于 2019-12-22 09:47:32
问题 Need to be route looks like #/routeName/?param1=aaaa&param2=bbb added to sammy #/routeName/:param1/:param2 and #/routeName/?:param1&:param2 none of them works 回答1: I've been looking into query parameters myself in Sammy.js, and discovered that (although it isn't mentioned in the API docs), Sammy does support query parameters. It simply adds any query parameters that it finds in your route to the route's Sammy.EventContext.params array. If you have a route structured like this: Sammy(function(

Weird redirect using data-bind submit, sammy.js and knockout.js together

筅森魡賤 提交于 2019-12-20 09:54:25
问题 I have a form like this on my page: <form data-bind="submit: AddFolder"></form> If I have this code in my JS script (of course I've removed all of the unrelated code and tested to make sure I can still recreate with only this code, normally you'll have more code inside here like .get and .post functions): Sammy(function() { }).run(); When the form is submitted, the page redirects to a weird URL like ?ko_unique=1 If I remove the Sammy part from my script, this doesn't happen. I think it has

How can I move to an anchor on a page when I'm using Sammy.js? [duplicate]

孤者浪人 提交于 2019-12-19 08:51:56
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to scroll HTML page to given anchor using jQuery or Javascript? I'm using Sammy.js, and it handles all the client-side URL navigation. I want to navigate to /page#fragment , but the page wont actually go to #fragment . How can I make it do that, either automatically, or by writing code to go to the fragment? 回答1: Sammy doesnt automatically trigger the route, so in your handler you need to add: hash = window

Prevent user to leave the route in a single page app with hashbang

試著忘記壹切 提交于 2019-12-18 07:09:00
问题 I am using Sammy.js for my single page app. I want to create functionality similar to SO (the one when you type your question and try to leave the page and it is asking you if you are sure). If it would not be a single page app, I would just do something like: $(window).bind('beforeunload', function(){ return 'Are you sure you want to leave?'; }); The problem is that in single page app user do not actually leave the page, but rather changing his document.location.hash (he can leave the page

Scroll to anchor link in a Sammy.js project

梦想与她 提交于 2019-12-14 02:00:17
问题 I am building a website using the sammy.js framework. I have a sidebar that is constant, and the main content view which loads the different pages with the help of sammy. On the side bar I have links to news articles. Currently any of the article links on the sidebar just load the #/news route. But I'd like it load the route and scroll down to the article. I've tried having an anchor link trigger once the route is loaded to scroll down to the article, but I get errors with the sammy app. Any

knockout sammy.js navigation issue

元气小坏坏 提交于 2019-12-13 18:20:12
问题 I have a scenario like this. Initially loaded when page is navigated to #Action. Once the select action is performed data-bind="with tag is loaded" User click on "Do Something" action is performed. Which replaces the whole "parentNode" Now When the user clicks back, and the sammy.js notices the hash tag #Action/:id, I need to load the #Action to get back the main View and then select the id to load the data-bind="with" tag again. How can I do this? Currently the page does go back to "Action/

Ignore an anchor in DurandalJS app

对着背影说爱祢 提交于 2019-12-13 14:23:35
问题 I have an SPA app using DurandalJS that works great. Links are routed, view models are activated, etc. The problem is, I have an anchor that points to a page that actually lives on the server. I need the browser to actually query this page (it's an asp.net MVC page). It seems the router in Durandal hooks into all links that are relative (or on the same domain, really) and if it finds no route, calls the handleInvalidRoute method of router. I cannot for the life of me figure out how to tell

knockout js data binding not updated

非 Y 不嫁゛ 提交于 2019-12-13 05:15:24
问题 I am working on a SPA that contains multiple areas that I dynamically load into a div (id=#main). In order to achieve such I use SammyJS for the routing and knockoutjs for the binding. The particular subpage is loaded like $('#main').load('pages/subpage.html'); where the subpage contains two divs that are switched (master/detail pattern). The data is loaded using .getJSON('data.php',....) into an observableArray within the knockout Model created. Everything works fine and a list of the items

Setting a knockout observable using sammy for routing

*爱你&永不变心* 提交于 2019-12-11 20:16:19
问题 I have a SPA using knockout JS for data binding and sammy for routing. I have a deck of cards that I am trying to have a dynamic routing to. My problem is that it doesn't work when I try to set a knockout observable from the routing function in sammy. My HTML, where I try to bind the name of the deck, looks like this: <!-- Create Deck --> <div id="createDeck" class="page" style="display:none;"> <input type="text" class="form-control" placeholder="Untitled Deck..." data-bind="value: $root.deck

router.guardRoute is not being called

对着背影说爱祢 提交于 2019-12-11 08:56:20
问题 This is probably a simple one.. I am trying to override the routers guardRoute function and it seems that my version is not being called. Code app.start().then(function () { router.useConvention(); viewLocator.useConvention(); app.setRoot('viewmodels/shell', 'entrance'); router.handleInvalidRoute = function (route, params) { logger.logError('No route found', route, 'main', true); }; router.guardRoute = function (routeInfo, params, instance) { logger.logError('guardRoute called', routeInfo,