Skip to content

Instantly share code, notes, and snippets.

@mrb
Forked from quirkey/way 1.js
Created April 26, 2009 21:13
Show Gist options
  • Save mrb/102175 to your computer and use it in GitHub Desktop.
Save mrb/102175 to your computer and use it in GitHub Desktop.
var Favorite = {
client_name: "",
client_id: "",
user_id: "",
add_or_remove: "",
getID: function(params){
this.client_name = params.attr("client_name");
this.client_id = params.attr("client_id");
this.user_id = params.attr("user_id");
this.add_or_remove = params.attr("add_or_remove");
},
post_action: function(params){
this.getID(params);
var fav = this;
$.post('/users/'+this.user_id+'/'+this.add_or_remove+'_favorites.js',
{
id: this.user_id,
authenticity_token: token,
client_id: this.client_id
},
function(data) {
fav.update_page.apply(fav)
});
},
update_page: function(){
$("#flash").text("Favorite Added");
$("#flash").slideDown();
$("#items").prepend("<li class='client' id="+this.client_id+">&nbsp;&nbsp;&nbsp;"+this.client_name+"</li>");
$("#"+this.client_id).show();
}
};
$.extend({
shove: function(fn, object) {
return function() {
return fn.apply(object, arguments);
}
}
});
var Favorite = {
client_name: "",
client_id: "",
user_id: "",
add_or_remove: "",
getID: function(params){
this.client_name = params.attr("client_name");
this.client_id = params.attr("client_id");
this.user_id = params.attr("user_id");
this.add_or_remove = params.attr("add_or_remove");
},
post_action: function(params){
this.getID(params);
$.post('/users/'+this.user_id+'/'+this.add_or_remove+'_favorites.js',
{
id: this.user_id,
authenticity_token: token,
client_id: this.client_id
},
$.shove(this.update_page, this));
},
update_page: function(){
$("#flash").text("Favorite Added");
$("#flash").slideDown();
$("#items").prepend("<li class='client' id="+this.client_id+">&nbsp;&nbsp;&nbsp;"+this.client_name+"</li>");
$("#"+this.client_id).show();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment