@@ -61,15 +61,15 @@ jQuery( function( $ ) {
61
61
var titleCell = $ ( '<td/>' ) . appendTo ( row ) ;
62
62
$ ( '<a/>' , {
63
63
'href' : post . link ,
64
- text : post . title . rendered
64
+ html : post . title . rendered
65
65
} ) . appendTo ( titleCell ) ;
66
66
67
67
// Post Author
68
68
var author = users [ post . author . toString ( ) ] ;
69
69
var authorCell = $ ( '<td/>' ) . appendTo ( row ) ;
70
70
$ ( '<a/>' , {
71
71
'href' : author . link ,
72
- text : author . name
72
+ html : author . name
73
73
} ) . appendTo ( authorCell ) ;
74
74
75
75
// Sticky
@@ -80,7 +80,11 @@ jQuery( function( $ ) {
80
80
stickyInput . prop ( 'checked' , post . sticky ) ;
81
81
82
82
stickyInput . on ( 'change' , function ( evt ) {
83
- toggleSticky ( post , stickyInput ) ;
83
+ stickyInput . prop ( 'disabled' , true ) ;
84
+ var props = {
85
+ sticky : ( ! post . sticky )
86
+ } ;
87
+ updatePost ( post , props ) ;
84
88
} ) ;
85
89
86
90
return row ;
@@ -139,20 +143,15 @@ jQuery( function( $ ) {
139
143
} ) ;
140
144
} ;
141
145
142
- // Toggles the sticky state of a post.
143
- var toggleSticky = function ( post , checkbox ) {
144
- var sticky = ! post . sticky ;
145
- checkbox . prop ( 'disabled' , true ) ;
146
+ var updatePost = function ( post , props ) {
146
147
147
148
$ . ajax ( {
148
149
url : screen_data . api_root + 'wp/v2/posts/' + post . id ,
149
150
method : 'POST' ,
150
151
beforeSend : function ( req ) {
151
152
req . setRequestHeader ( 'X-WP-Nonce' , screen_data . api_nonce ) ;
152
153
} ,
153
- data : {
154
- 'sticky' : sticky
155
- } ,
154
+ data : props ,
156
155
success : function ( data ) {
157
156
// Update the global state
158
157
regeneratePost ( data ) ;
0 commit comments