1

I currently have a model called project_todo and it has a column called done that is a boolean. I have it setup so I can currently drag this from one side of the app to the other, dragging it from todo to done. However, it doesn't save obviously.

What I need to do is on drag toggle the boolean and I believe what I need to do is post via JS/jquery to the update path to do it. However, I'm not exactly sure what this should look like.

Can anyone give me some example code and/or point me in the right direction.

So I could do something like this:

$.ajax({
  type: 'POST',
  url: '/project_todo/<%project_todo.id%>/edit',
});

1 Answer 1

1

let's say we have a link that clicking on it should update the column:

<%= link_to 'update project', edit_project_todo_path(project_todo), :class => 'updateProject' %>

then js may look like:

$('.updateProject').click(function(event) {
  event.preventDefault();

  $.ajax({
    type: 'POST',
    url: $(event.target).attr('href')
  });
});

You can do this with any event you want, if it's a form you can use action attribute of the form

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.