jquery - Using AJAX to delete/edit items from a list -


I have a list of tickets that are being displayed using the loop running through my viewold Until I am using Ajax. Benefit but I want to change it so that I can use junkery and AJX. How do I create it so that I can use the right values ​​from JQUERY I know that this naming scheme has something to do with the schema, but it can not remember how to do it (it was done when I took up my web development class some time ago). Below is the code for my table / ticket list output. <

  @forach (variable ticket in model ticket) {& lt; Tr class = "viewTickTr" & gt; & Lt; Td class = "viewTickTd" & gt; & Lt; Label id = "ticketId" & gt; @ticket.id & lt; / Label & gt; & Lt; / TD & gt; & Lt; Td class = "viewTickTd" & gt; & Lt; Label id = "dateCreated" & gt; @ Ticket.dateCreated & lt; / Label & gt; & Lt; / TD & gt; & Lt; Td class = "viewTickTd" & gt; & Lt; Label id = "supportStaffId" & gt; @ Ticket.supportStaffID & lt; / Labels & gt; & Lt; / TD & gt; & Lt; Td class = "viewTickTd" & gt; & Lt; Label id = "empId" & gt; @ Ticket.empId & lt; / Label & gt; & Lt; / TD & gt; & Lt; Td class = "viewtecdid" & gt; & Lt; / Td> & Lt; Td class = "viewTickTd" & gt; & Lt; Label id = "categoryId" & gt; @ Ticket.categoryId & lt; / Labels & gt; & Lt; / TD & gt; & Lt; Td class = "viewTickTd" & gt; & Lt; Label id = "severityId" & gt; @ Ticket.severityId & lt; / Labels & gt; & Lt; / TD & gt; & Lt; Td class = "viewTickTd" & gt; & Lt; Label id = "statusId" & gt; @ticket.statusId & lt; / Label & gt; & Lt; / TD & gt; & Lt; Td class = "viewTickTd" & gt; & Lt; Input type = "button" value = "edit" class = "ticket edit button" /> & Lt; / TD & gt; & Lt; Td class = "viewTickTd" & gt; & Lt; Input type = "button" value = "delete" class = "ticketDeleteButt" id = "deleteTickBtn" /> & Lt; / TD & gt; & Lt; / TR & gt; }  

I have a data-id attribute And populate it with the ticket id, when you click the button, grab the ID from the attribute and pass it along with your AJAX call.

  & lt; Input type = "button" data-id = "@ ticket.id" value = "delete" class = "ticketDeleteButt" />  

Notice that I removed id = "deleteTickBtn" , having many items with the same ID will cause problems in IE.

  You will want to remove them from all your rows to get $ (documents)   

in jQuery .ready (function () {$ (". TicketDeleteButt "). Click (function (e) {e.preventDefault (); var id = $ (this) .attr (" data-id "); // Make Make AJAX call}}

Then you can do something for your editing, except that the user will click on your button on the edit page


Comments

Popular posts from this blog

Active Directory Authenticated Proxy Server with Squid or CNTLM -

java - @PluginTarget(Node.class) not registering as neo4j plugin -

python - Calculate STD manually using Groupby Pandas DataFrame -