sammy.js

declare routes in sammy js in typescript

大兔子大兔子 提交于 2019-12-10 20:08:00
问题 I would like to use the definitely typed sammyjs file in conjunction with typescript to declare a route on my page Javascript for the declaration would look like this --> Sammy(function () { this.get('#:foobar', function () { //doStuff var baz = this.params.foobar; }); this.get('', function () { this.app.runRoute('get', '#All') }); }).run(); So far I have this. var app: Sammy.Application = Sammy(); app.get('#:foobar', () => { //doStuff var baz = this.params.foobar; }); Obviously params is not

Change hash without triggering Sammy event

橙三吉。 提交于 2019-12-10 12:35:56
问题 function UsersVM(start_page){ var self = this; console.log('start form ' + start_page); self.go_to = function(page) { location.hash = '#Users/' + pageNumber; } } Sammy(function() { this.get('/app/?#Users/:page', function () { var vm = new UsersVM(this.params.page); ko.applyBinding(vm); }); }).run(); I would like to change the page's hash with the following code: location.hash = '#Users/' + pageNumber; But in this case Sammy triggers routing. Say in Backbone we can do it this way: app.navigate

Comparison between Sammy.js/History.js/Nav.js [closed]

三世轮回 提交于 2019-12-09 06:42:48
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I was looking around for Single Page navigation handlers. Sammy.js was bit okay to crack so i created a sample SPA with proper

How to prevent form submit

杀马特。学长 韩版系。学妹 提交于 2019-12-07 04:54:42
问题 I am using KnockoutJS with SammyJS for one page application. In the html I have form tag as follow <form data-bind='submit: search'> <label>Find user:</label> <input data-bind='value: name' /> </form> and in my viewmodel, declared two functions and sammy route url function ViewModel() { var self = this; self.name = ko.observable(""); self.search = function () { alert(self.name); }; Sammy(function () { this.get('#:id', function () { //do something.... }); }).run(); } ko.applyBindings(new

How to prevent form submit

限于喜欢 提交于 2019-12-05 08:51:44
I am using KnockoutJS with SammyJS for one page application. In the html I have form tag as follow <form data-bind='submit: search'> <label>Find user:</label> <input data-bind='value: name' /> </form> and in my viewmodel, declared two functions and sammy route url function ViewModel() { var self = this; self.name = ko.observable(""); self.search = function () { alert(self.name); }; Sammy(function () { this.get('#:id', function () { //do something.... }); }).run(); } ko.applyBindings(new ViewModel()); All code works good, until I type something in textbox then submit the form. I expected no url

Rails Client side / Server side rendering using single template (handlebars or Mustache) with Sammy.js

心已入冬 提交于 2019-12-05 02:20:45
问题 I've searched the web for a while looking for a tutorial, but haven't had much luck. From what I understand, Twitter is using a single Mustache.js template in rails to render from the server on first page load, and then through their own ajax transition system (much like sammy.js). I can get handlebars and sammy.js loaded in rails, but I can't figure out how to share a single template file from server(rails) & client(sammy) side. 回答1: I have not personally built anything where I've used the

performance / templating issues when using requirejs with JQuery, jQuery Mobile, Knockout and Sammy to build a structured app with External Templates

烈酒焚心 提交于 2019-12-04 05:06:52
问题 I have a setup for a test app which includes require.js, jQuery, jQueryMobile (jqm), knockout and sammy require.js loads in jqm, knockout and sammy on the app main page i use sammy to load in knockout viewModels. these viewModels the load in the templates.. so to show the code... require page: require.config({ jquery: 'vendor/jqm/jquery_1.7_min', jqm: 'vendor/jqm/jquery.mobile-1.1.0', knockout: 'vendor/knockout/knockout-2.2.0', sammy : 'vendor/sammy/sammy', text: 'vendor/require/text', views:

Cancel route using Sammy.js without affecting history

a 夏天 提交于 2019-12-04 03:40:29
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.history.back (yuk) to go back to the original spot in the history or sammy.redirect. Both of which are less

Comparison between Sammy.js/History.js/Nav.js [closed]

杀马特。学长 韩版系。学妹 提交于 2019-12-03 08:41:38
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. I was looking around for Single Page navigation handlers. Sammy.js was bit okay to crack so i created a sample SPA with proper navigation. Works great till now.(moreover, the fact the sammy.js is used by Twitter.. made me more curious.. ) :) No issues!!

Command-click doesn't open a new tab, but middle-click does

喜夏-厌秋 提交于 2019-12-03 08:22:08
问题 On my website, which is a one-page JS site using Sammy.js and jQuery, when I middle-click a link with a mouse, the link opens in a new tab. But when I command-click on a Mac, it doesn't. This happens in both Firefox and Chrome, so I assume it must be according to spec in some way. This happens on a Macbook Air (so trackpad + command button). Most sites work just fine though, with command-click being identical to normal middle-click. Try it out yourself: https://circleci.com. Command-click