added disabled state to submit when no model is selected

This commit is contained in:
Victor Nguyen 2013-03-05 00:05:27 +11:00
parent 58840ba128
commit ea3bbc4ebd
3 changed files with 17 additions and 2 deletions

View file

@ -10,7 +10,7 @@
h3 { text-align:center; padding-bottom:0.8em; } h3 { text-align:center; padding-bottom:0.8em; }
#modal-trigger { display:block; margin:1em auto; } #modal-trigger { display:block; margin:1em auto; }
#help { font-size:13px; margin-left:15px; opacity:0.7 }

View file

@ -14,6 +14,7 @@
$modifier = $('#modifier input'), $modifier = $('#modifier input'),
$minified = $('#minified input'), $minified = $('#minified input'),
$submit = $('#submit'); $submit = $('#submit');
$help = $('#help');
// bind event handlers // bind event handlers
$options.click( _handleSelect ); $options.click( _handleSelect );
@ -26,6 +27,7 @@
e.preventDefault(); e.preventDefault();
_setSelectedModel(this); _setSelectedModel(this);
_setSelectLabel(model.name); _setSelectLabel(model.name);
_enableSubmit();
} }
function _handleSubmit(e) { function _handleSubmit(e) {
@ -54,6 +56,16 @@
$submit.button('reset'); $submit.button('reset');
} }
function _disableSubmit() {
$submit.attr('disabled', 'disabled');
// $help.fadeIn(100);
}
function _enableSubmit() {
$submit.removeAttr('disabled');
// $help.fadeOut(100);
}
function _setSelectedModel(option) { function _setSelectedModel(option) {
var $option = $(option); var $option = $(option);
model = { model = {

View file

@ -18,7 +18,10 @@ block content
label#minified.checkbox label#minified.checkbox
input(type='checkbox', checked) input(type='checkbox', checked)
| Minified output | Minified output
button#submit.btn.btn-primary.btn-large(data-loading-text='Fetching specs...') Get Specs button#submit.btn.btn-primary.btn-large(disabled, data-loading-text='Fetching specs...') Get Specs
//- span#help.help-inline
//- i.icon-exclamation-sign
//- | Select a model first!
div#results.row-fluid div#results.row-fluid
div.span4 div.span4
h3 Model Name h3 Model Name