MCPcopy Create free account
hub / github.com/azat-co/practicalnode / update

Function update

code/ch10/grunt-example/source/admin.js:29–51  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

27};
28
29var update = function(event) {
30 var $tr = findTr(event);
31 $tr.find('button').attr('disabled', 'disabled');
32 var data = {
33 published: $tr.hasClass('unpublished')
34 };
35 var id = $tr.attr('data-id');
36 $.ajax({
37 url: '/api/articles/' + id,
38 type: 'PUT',
39 contentType: 'application/json',
40 data: JSON.stringify({article: data}),
41 success: function(dataResponse, status, xhr) {
42 $tr.find('button').removeAttr('disabled');
43 $('.alert').addClass('hidden');
44 if (data.published) {
45 $tr.removeClass('unpublished').find('.glyphicon-play').removeClass('glyphicon-play').addClass('glyphicon-pause');
46 } else {
47 $tr.addClass('unpublished').find('.glyphicon-pause').removeClass('glyphicon-pause').addClass('glyphicon-play');
48 }
49 }
50 });
51};
52
53$(document).ready(function(){
54 var $element = $('.admin tbody');

Callers

nothing calls this directly

Calls 1

findTrFunction · 0.70

Tested by

no test coverage detected