ga-dc / wdi5-project3

Project 3
0 stars 5 forks source link

ajax call drag and drop to change params #83

Closed janicemin closed 9 years ago

janicemin commented 9 years ago

Trying to drag an article of clothing from an owner's closet to a borrower's closet and retain garment ID and when they're dropped into another div element?

i keep getting an error that says in the console: Failed to load resource: the server responded with a status of 404 (Not Found) jquery.self-d03a5518f45df77341bdbe6201ba3bfa547ebba8ed64f0ea56bfa5f96ea7c074.js?body=1:9660 POST http://localhost:3000/closets/update 404 (Not Found)

        var params = {};

$( ".draggable" ).draggable({ snap: true, drag: function() { params = { id: $(this).data('garmentId'), profileID: $(this).data('profileId'), name: $(this).data('name') };
} });

$( ".column-style" ).droppable({ activeClass: "ui-state-default", hoverClass: "ui-state-hover", drop: function( event, ui ) { params.method = "update"; $.ajax({ method: "post", url:"/closets/update", data: $.param(params) }); // console.log('hi'); // console.log($(this).data('index')); } });



 });```

here is my github page: https://github.com/janicemin/project3-canborrow
jshawl commented 9 years ago

url:"/closets/update", this is not the url for updating items. I think you need url:"/closets/3" or the id of the closet that you're updating.

janicemin commented 9 years ago

i tried an id and still getting the same error...

jshawl commented 9 years ago

can you post your code and / or visit the genius bar / or push code to github

janicemin commented 9 years ago

yes, https://github.com/janicemin/project3-canborrow

jshawl commented 9 years ago

it still looks like you're using the update url? https://github.com/janicemin/project3-canborrow/blob/master/app/assets/javascripts/application.js#L41

janicemin commented 9 years ago

i changed it in my latest code. that's the one i want to keep in case i f things up :)

janicemin commented 9 years ago

i'm just not sure where to go from here. i can get it to borrow and persist in the database as i want as a rails, but i'm trying to make this an ajax call so i can meet the requirements....

jshawl commented 9 years ago

ok id be happy to take a look if you paste the update you made in here

janicemin commented 9 years ago

url:"/closets/update" + 'profileId', just trying something.

janicemin commented 9 years ago

hey @jshawl , could you point me into the right direction of how i should set it up? just not sure... params = { profileID: $(this).data('profileId'), }; url:"/closets/update" + profileID is that kind of where i'm supposed to be?

janicemin commented 9 years ago

i got an undefined profileID error, so i am trying to define it within the drop function....