-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
before-sort now called during initialization
fixes #87
- Loading branch information
Showing
3 changed files
with
86 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Bootstrap Sortable Tables</title> | ||
</head> | ||
<body> | ||
<table class='sortable'> | ||
<thead> | ||
<tr> | ||
<th id="h1" data-defaultsort="asc">h1</th> | ||
<th id="h2">h2</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr id="az"> | ||
<td id="a">a</td> | ||
<td id="z">z</td> | ||
</tr> | ||
<tr id="by"> | ||
<td id="b">b</td> | ||
<td id="y">y</td> | ||
</tr> | ||
<tr id="cx"> | ||
<td id="c">c</td> | ||
<td id="x">x</td> | ||
</tr> | ||
<tr id="dw"> | ||
<td id="d">d</td> | ||
<td id="w">w</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
jasmine.getFixtures().fixturesPath = 'base/Tests/'; | ||
|
||
describe('Events raising', function () { | ||
beforeEach(function () { | ||
jasmine.getFixtures().load('eventsRaising.html'); | ||
}); | ||
|
||
it("before-sort is raised on initialization", function () { | ||
var table = $('table.sortable'); | ||
var wasRaised = false; | ||
table.on('before-sort', function() { | ||
wasRaised = true; | ||
}); | ||
$.bootstrapSortable(); | ||
expect(wasRaised).toBe(true); | ||
}); | ||
|
||
it("sorted is raised on initialization", function () { | ||
var table = $('table.sortable'); | ||
var wasRaised = false; | ||
table.on('sorted', function () { | ||
wasRaised = true; | ||
}); | ||
$.bootstrapSortable(); | ||
expect(wasRaised).toBe(true); | ||
}); | ||
|
||
it("before-sort is raised on manual sorting", function () { | ||
var table = $('table.sortable'); | ||
var wasRaised = false; | ||
$.bootstrapSortable(); | ||
table.on('before-sort', function () { | ||
wasRaised = true; | ||
}); | ||
$.bootstrapSortable({ sortingHeader: $('#h2') }); | ||
expect(wasRaised).toBe(true); | ||
}); | ||
|
||
it("sorted is raised on manual sorting", function () { | ||
var table = $('table.sortable'); | ||
var wasRaised = false; | ||
$.bootstrapSortable(); | ||
table.on('sorted', function () { | ||
wasRaised = true; | ||
}); | ||
$.bootstrapSortable({ sortingHeader: $('#h2') }); | ||
expect(wasRaised).toBe(true); | ||
}); | ||
}) |