A few easy questions
A few easy questions
Hello, everyone,
The question is rather simple. How do I ( with example, please ) ;
1. Create a simple update/delete user interface
2. Use at least one jQuery UI, such as sortable, draggable, dialog,... )
3. Add a jQuery animation
Thank you in advance! :D
- $(document).ready(function(){
- var API=" http://193.246.33.24/data/ "
- var users = $("#users");
-
- $.get(API, {user:13}, function(data){
- $.each(data, function(i, usr){
- addUser(usr);
- });
- });
-
- function addUser(usr){
- users.append("<tr data-id=" + usr.id + "><td>"+ usr.name + "</td><td>" + usr.surname + "</td><td><button class='btn btn-danger delete'>Delete</button></td></tr>");
-
- };
-
- var dialog = $( "#dialog" ).dialog({
- autoOpen : false,
- modal : true,
- buttons:{
- "Dodaj novog" : function(){
- form.submit();
- },
- Cancel: function(){
- dialog.dialog("close")
- }
- },
- close: function() {
- form[0].reset();
- }
- });
- $("#addNew").on("click", function(){
- dialog.dialog("open");
- });
-
- var form = dialog.find("form");
-
- form.on("submit", function(e){
- e.preventDefault();
-
- $.post(API + "create", form.serialize()).done(function(data){
- addUser(data);
- dialog.dialog("close");
- }).fail(function(error) {
- console.log(error.responseText);
- })
-
- });
-
- users.on("click",".delete", function(){
- var row = $(this).closest("tr");
- $.post(API + "destroy/" + row.data("id"), {}, function(data){
- row.fadeOut(function(){
- $(this).remove();
- });
- });
- });
-
-
- });
193.246.33.24
[ { "user": 999, "name": "Pero", "surname": "Perić", "createdAt": "2015-05-29T11:46:00.034Z", "updatedAt": "2015-05-29T11:49:26.915Z", "id": 7 }, { "user": 2, "name": "Bareuu", "surname": "svirajMajkeu", "createdAt": "2015-05-29T11:51:56.808Z", "updatedAt": "2015-05-29T11:56:51.319Z", "id": 10, "hob…
193.246.33.24