sammy.js

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

我怕爱的太早我们不能终老 提交于 2019-12-02 23:46:26
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 between "about", "home" and "contact" and you should experience the problem - they don't open in new tabs

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

蓝咒 提交于 2019-12-02 20:38:37
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 something to do with event bubbling and Sammy and Knockout both hooking the onSubmit, and the browser

From the server is there a way to know that my page is being loaded in an Iframe

只愿长相守 提交于 2019-12-02 07:49:29
问题 I am using sammy.js in my webpage, and if someone uses this webpage in an IFrame (for IE), it will simply redirect the whole page to the location of the IFrame.So, I was thinking if there is a way to check if my page is being requested by an IFrame.If that is the case, then I can simply disable sammy(change lines that play with top.location). I was thinking that a browser would be sending a few more headers , when a page is loaded in an IFrame. 回答1: You can do this using javascript with the

Durandal Multiple Master Pages

馋奶兔 提交于 2019-11-30 16:57:13
问题 I am working on a SPA that I would like to use multiple master views. Here is my use case: I have a user that has a profile page. Within that profile page I would like to be able to display a couple of different views, ie. details, works, contact info, etc. I need to be able to deep link to each of these views. Each of these views must display the basic user data from the master layout view. It is my understanding that I should be using compose for this and I have a bit of code that seems to

sammyjs optional parameters

偶尔善良 提交于 2019-11-30 14:19:53
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 if its been supplied. Any tips on this? Sammy actually dropped the ball when it comes to optional

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

六月ゝ 毕业季﹏ 提交于 2019-11-29 12:12:47
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 by closing it). Is there a way to make something similar for a SPA, preferably with sammy.js? We had a