Closed docyes closed 12 years ago
At the moment Agility won't include the root element of a view in the event selector (this behavior can be traced back to jQuery), so the controller submit form
doesn't pick up any element.
To get around it, you can either explicitly select the root element with submit &
(see http://agilityjs.com/docs/docs.html#events-dom), or create a dummy root element for your view so that the form
selector is picked up by jQuery:
var searchbar = $$({
model:{},
view:{
format:
'<div>\
<form> \
<input type="search"> \
<input type="submit" value="search"> \
</form> \
</div>',
style:
'& input[type="search"] {width:70%;} \
& input[type="submit"] {width: 10%;}'
},
controller:{
'submit form': function(){
alert(16);
}
}
});
$$.document.append(searchbar);
Thanks, totally reasonable!
I can't seem to setup an event listener for the submit event on a form. See example below...
var searchbar = $$({ model:{}, view:{ format: '
', style: '& input[type="search"] {width:70%;} \ & input[type="submit"] {width: 10%;}' }, controller:{ 'submit form': function(){ alert(16); } } }); $$.document.append(searchbar);