jquery-editable: Automatically call backend if route and id attributes are present
[infodrom.org/service.infodrom.org] / src / jquery.editable.js
index 406b3db..d091608 100644 (file)
                                 $el : $el
                             });
                         }
+                       else {
+                           var route = $($el).attr('route');
+                           var name = $($el).attr('name');
+                           var item_id = $($el).attr('item_id');
+                           if (typeof(route) == 'string' && typeof(item_id) == 'string')
+                               $.invoke(route,
+                                        {id: item_id,
+                                         name: name,
+                                         content: newText == defaultText ? false : newText});
+                       }
                     };
 
                     // Blur editor when user clicks outside the editor
                             $el : $el
                         });
                     }
+                   else {
+                       var route = $($el).attr('route');
+                       var name = $($el).attr('name');
+                       var item_id = $($el).attr('item_id');
+                       if (typeof(route) == 'string' && typeof(item_id) == 'string')
+                           $.invoke(route,
+                                    {id: item_id,
+                                     name: name,
+                                     content: newText == defaultText ? false : newText});
+                   }
                 })
                 .attr('style', textareaStyle)
                 .appendTo($el)