Skip to content

Instantly share code, notes, and snippets.

@beneggett
Created June 10, 2014 21:57
Show Gist options
  • Save beneggett/c9f0ffe2d05ba9efebba to your computer and use it in GitHub Desktop.
Save beneggett/c9f0ffe2d05ba9efebba to your computer and use it in GitHub Desktop.
$("#merchants-list tbody tr ").find('td:first :checkbox').each(function(){
var $target = $(this),
value,
$indicator;
if ( $target.hasClass( "checkbox" ) ) {
// Check the check box
value = "1";
$target.parents("tr:first").find("td:first :checkbox").attr("checked","checked");
$indicator = $("<img src=\"/images/loader.dots.gif\" class=\"update-checkbox\" />");
$target.parents( "td:first" ).append( $indicator );
$.ajax({
type: "put",
url: "http://popshops.com/dashboard2/catalogs/ajzkifi83totb39qso1sj1ztc",
data: "merchant[id]=" + $target.val() + "&merchant[active]=" + value + "&v=2.3&feed_type=both",
dataType: "json",
complete: function() {
$indicator.remove();
$target.show();
},
success: function() {
$target.parents( "tr:first" ).effect( "highlight" );
},
error: function(XMLHttpRequest) {
window.alert( $.parseJSON( XMLHttpRequest.responseText ).message );
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment