Last active
August 29, 2015 13:56
-
-
Save tbrd/8955436 to your computer and use it in GitHub Desktop.
A search form component for Flight
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
define(function (require) { | |
'use strict'; | |
/** | |
* Module dependencies | |
*/ | |
var defineComponent = require('flight/lib/component'); | |
/** | |
* Module exports | |
*/ | |
return defineComponent(searchForm); | |
/** | |
* Module function | |
*/ | |
function searchForm() { | |
this.defaultAttrs({ | |
keywordInputSelector: '.js-keywords' | |
}); | |
this.after('initialize', function () { | |
this.on('submit', this.handleSubmit); | |
}); | |
this.handleSubmit = function (event) { | |
// prevent submit event from bubbling | |
event.preventDefault(); | |
// get the value of .js-keywords | |
var keywords = this.select('keywordInputSelector').val(); | |
// broadcast keywords | |
this.trigger('ui-keywords', { | |
keywords: keywords | |
}); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment