mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
In KnockoutSpa template, fix handling clicks on descendants of A elements. Fixes #273.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import * as ko from 'knockout';
|
||||
import * as $ from 'jquery';
|
||||
import crossroads = require('crossroads');
|
||||
|
||||
// This module configures crossroads.js, a routing library. If you prefer, you
|
||||
@@ -28,7 +29,7 @@ export class Router {
|
||||
// Make history.js watch for navigation and notify Crossroads
|
||||
this.disposeHistory = history.listen(location => crossroads.parse(location.pathname));
|
||||
this.clickEventListener = evt => {
|
||||
let target: any = evt.target;
|
||||
let target: any = evt.currentTarget;
|
||||
if (target && target.tagName === 'A') {
|
||||
let href = target.getAttribute('href');
|
||||
if (href && href.charAt(0) == '/') {
|
||||
@@ -38,12 +39,12 @@ export class Router {
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener('click', this.clickEventListener);
|
||||
$(document).on('click', 'a', this.clickEventListener);
|
||||
}
|
||||
|
||||
public dispose() {
|
||||
this.disposeHistory();
|
||||
document.removeEventListener('click', this.clickEventListener);
|
||||
$(document).off('click', 'a', this.clickEventListener);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
},
|
||||
"isomorphic-fetch/isomorphic-fetch.d.ts": {
|
||||
"commit": "57ec5fbb76060329c10959d449eb1d4e70b15a65"
|
||||
},
|
||||
"jquery/jquery.d.ts": {
|
||||
"commit": "f470e7569e7046c62866f57bc4fea56ba79975d5"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
3242
templates/KnockoutSpa/typings/jquery/jquery.d.ts
vendored
Normal file
3242
templates/KnockoutSpa/typings/jquery/jquery.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
templates/KnockoutSpa/typings/tsd.d.ts
vendored
1
templates/KnockoutSpa/typings/tsd.d.ts
vendored
@@ -6,3 +6,4 @@
|
||||
/// <reference path="crossroads/crossroads.d.ts" />
|
||||
/// <reference path="js-signals/js-signals.d.ts" />
|
||||
/// <reference path="isomorphic-fetch/isomorphic-fetch.d.ts" />
|
||||
/// <reference path="jquery/jquery.d.ts" />
|
||||
|
||||
Reference in New Issue
Block a user