New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Raise an event when all views in a given selector are closed #454
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ef1a20a
Raise an event when all views in a given selector are closed #453
gjlubbertsen 0588d53
Update test names and include link to issue
gjlubbertsen a9b611d
Fixed code style issues to match the guide
gjlubbertsen c8c8d4f
Fixed code style issues to match the guide
gjlubbertsen 410a082
Rename the event + minor formatting changes
gjlubbertsen File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 |
---|---|---|
|
@@ -1704,6 +1704,48 @@ test("Allow layout to remove views", 2, function() { | |
equal(view.getViews().value().length, 0, "All nested views under lol removed"); | ||
}); | ||
|
||
//https://github.com/tbranyen/backbone.layoutmanager/issues/453 | ||
test("Raise an event when all views in a given selector are closed", 3, function() { | ||
|
||
var eventCame = false; | ||
var foundSelector = ""; | ||
|
||
var view = new Backbone.Layout({ manage: true }); | ||
view.on("removedLastViewForSelector", function (selector) {eventCame = true; foundSelector = selector;} ); | ||
|
||
var firstSubView = new Backbone.Layout({ manage: true }); | ||
var secondSubView = new Backbone.Layout({ manage: true }); | ||
|
||
view.insertView("lol", firstSubView); | ||
view.insertView("lol", secondSubView); | ||
|
||
firstSubView.remove(); | ||
equal(eventCame, false, "Event not yet fired"); | ||
|
||
secondSubView.remove(); | ||
equal(eventCame, true, "Event got fired"); | ||
equal(foundSelector, "lol", "Right selector was given to event"); | ||
}); | ||
|
||
//https://github.com/tbranyen/backbone.layoutmanager/issues/453 | ||
test("Raise an event when all views in a given selector are closed single view case", 2, function() { | ||
|
||
var eventCame = false; | ||
var foundSelector = ""; | ||
|
||
var view = new Backbone.Layout({ manage: true }); | ||
view.on("removedLastViewForSelector", function (selector) {eventCame = true; foundSelector = selector;} ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These do not need to be a single condensed line, let em breathe on a new line :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure |
||
|
||
var firstSubView = new Backbone.Layout({ manage: true }); | ||
|
||
view.setView("lol", firstSubView); | ||
|
||
firstSubView.remove(); | ||
|
||
equal(eventCame, true, "Event got fired"); | ||
equal(foundSelector, "lol", "Right selector was given to event"); | ||
}); | ||
|
||
// https://github.com/tbranyen/backbone.layoutmanager/issues/238 | ||
asyncTest("Lost triggered events in cached sub-view", 2, function() { | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use 2 space soft tabs, please adjust.