jquery - Unable to delete object in Rails using Ajax -


Submit an app in Noob Rail 4 and delete in an attempt to make a simple note here. I am using Ajax to submit / delete, but I do not understand why my object will not be removed

My administrator includes the following removal method:

  Delete Def Note.Fund (Parameters [: ID]). Delete Render: json = & gt; "Note deleted!"   

My "Create" method is as follows:

  def Note = Note. Create (Title: Note_param [: Title], Description: "Click to add description") render: json = & gt; Note End   

In my application.js, I am using Ajax to submit and then I can create a "delete" button together:

 < Code> $ (document)). (Function () {$ ("form")} submit (function ($ .post ($ (this) .attr ('verb'), $ (this) .serialize (), function (data) {console Examples of things like $ ('all-notes') for example .log ('Data received from Ajax calls', data); // html to add additional code, etc. Append (data. title (); $ ('sub-notes'). enclosed ('& lt; input type = "button" square = "ajay" value = "delete"> gt;'}}, "json"); Return return;} );   

However, when I submit a note, then I will be asked with the related delete button The note appears, but in reality, clicking on the button is nothing. Delete the application.js file for my Ajax code here:

  $ (". Ajay"). Submit (Function () {$ .post ($ (this) .attr ('action'), $ (this) .serialize (), function (data) {console.log ('data received from ajax call', Data); // html code etc., for example, $ ('all notes'). Remove (data.title);}, "Jason"); Details is false; });   

Any ideas ? much appreciated!

-A

You should try to do something like this:

  $ ('. Ajay'). Live ('click', function () {$ .ajax ({url: '/ note / id', type: 'DELETE', success: function (result) {// do something with result}})}} ;    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -