Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cto
g1
Commits
30c3e9e7
Commit
30c3e9e7
authored
Feb 16, 2019
by
S Anand
Browse files
DOC: urlchange clearing, multi-listening. Fixes
#119
@karmanya.aggarwal
parent
6e93b42f
Pipeline
#77012
passed with stage
in 2 minutes and 13 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
docs/urlchange.md
View file @
30c3e9e7
...
...
@@ -52,6 +52,10 @@ Examples:
-
When the URL changes from
`#a`
to
`#b`
, it triggers 2 events on
`window`
:
-
`.on('#', function(e) { e.hash.pathname == 'b' }`
-
`.on('#/', function(e, val) { val == 'b' && e.old == 'a' }`
-
Combinations of keys can be listened to simultaneously
-
`.on('#?x #?y', function(e){})`
will only be triggered if both x and y change
-
When the hashkey is reset,
`location.hash=''`
-
`.on('#', function(e){})`
as the location.hash is now
`{}`
## $.urlchange events
...
...
test/test-urlchange.html
View file @
30c3e9e7
...
...
@@ -89,6 +89,27 @@
window
.
location
.
hash
=
'
#?x=1&y=2
'
})
tape
(
'
clearing x should still trigger an event
'
,
function
(
t
)
{
reset
(
'
#?x=1
'
)
t
.
plan
(
2
)
// One less than no. of tests. #?x.test should not be fired
$
(
window
).
one
(
'
#?x
'
,
function
(
e
,
val
)
{
t
.
deepEqual
(
e
.
hash
.
searchList
,
{})
t
.
deepEqual
(
e
.
old
.
searchList
,
{
'
x
'
:
[
'
1
'
]})
})
window
.
location
.
hash
=
''
})
tape
(
'
Adding #?abc=1&xyz=2 triggers on both abc and xyz events
'
,
function
(
t
)
{
reset
(
'
#?abc=1&xyz=1
'
)
t
.
plan
(
3
)
// One less than no. of tests. #?x.test should not be fired
$
(
window
).
one
(
'
#?abc #?xyz
'
,
function
(
e
,
val
)
{
t
.
equal
(
val
,
'
2
'
)
t
.
deepEqual
(
e
.
hash
.
searchList
,
{
'
abc
'
:
[
'
1
'
],
'
xyz
'
:
[
'
2
'
]
})
t
.
deepEqual
(
e
.
old
.
searchList
,
{
'
abc
'
:
[
'
1
'
],
'
xyz
'
:
[
'
1
'
]
})
})
window
.
location
.
hash
=
'
#?abc=1&xyz=2
'
})
tape
(
'
#a?x=1&y=2&z=3 -> #b?x=1&x=2&y=3
'
,
function
(
t
)
{
reset
(
'
#a?x=1&y=2&z=3
'
)
t
.
plan
(
18
)
...
...
S Anand
@s.anand
mentioned in merge request
!63 (closed)
·
Feb 16, 2019
mentioned in merge request
!63 (closed)
mentioned in merge request !63
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment