Skip to content

Instantly share code, notes, and snippets.

@iammerrick
Created May 31, 2010 01:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iammerrick/419452 to your computer and use it in GitHub Desktop.
Save iammerrick/419452 to your computer and use it in GitHub Desktop.
var GoalForm = new Class({
Implements: [Options, Events],
options:{
},
initialize: function(element, options){
this.setOptions(options);
this.element = $(element);
this.element.set('send', {
url: this.element.get('action'),
method: 'post',
onSuccess: function(){
this.addSuccess();
}.bind(this)
});
this.attachEvents();
},
attachEvents: function(){
this.element.getParent().addEvent('click', function(){
}.bind(this));
this.element.getElement('textarea').addEvent('blur', function(){
this.addNote();
}.bind(this));
this.element.getElement('textarea').addEvent('keydown', function(event){
if(event.key == 'enter'){
this.addNote();
}
}.bind(this));
},
addNote: function(){
this.element.send();
},
addSuccess: function(){
}
});
var GoalNotes = new Class({
Implements: [Options, Events],
options:{
base: '/',
goalID: $empty,
updateContainer: 'update_container'
},
initialize: function(elements, options){
this.setOptions(options);
this.elements = $$(elements);
this.request = new Request({
url: this.options.base + 'goals/note_form/',
onSuccess: function(reponseText){
$(this.options.updateContainer).set('html', responseText);
}
});
this.attachEvents();
},
attachEvents: function(){
this.elements.each(function(element){
element.addEvent('click', function(){
this.request.post('goal_id=' + this.options.goalID +'&timestamp=' + element.get('data-day'));
}.bind(this));
}.bind(this));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment