Writing the code inside 'domready' event
Pros * Writing the logic for a specific app is fast and furious * The test environment is the app & Cons * It’s much harder to maintain * A high percentage of code you write for the app isn’t reusable * The test environment is the app
by Piotr Zalewa
HTML
<form id='myForm' method='post' action='/ajax_html_echo/'>
<input type='text' name='html' value='Something to respond' />
<input type='submit' />
</form>
<p id='myContainer'></p>
CSS
#myContainer {
margin-top: 10px;
color: navy;
font-weight: bold;
}
JavaScript
window.addEvent('domready', function(){
$('myForm').addEvent('submit', function(evt){
evt.preventDefault();
this.set('send', {
onComplete: function(result){
$('myContainer').set('html', result);
}
});
this.send();
});
});