Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9052533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:11:51+00:00 2026-06-16T13:11:51+00:00

Currently, I am implementing a table with items(slot_allocations) in it. The items are based

  • 0

Currently, I am implementing a table with items(slot_allocations) in it. The items are based on a Rails model.
The items in the table can be dragged and dropped.

Right now, I am able to retrieve and show data of the model in my table.
I would however also like to update the information in the model after I have successfully drag and drop the item in a new cell and would like to seek advice on how I could go about doing so.

I am currently able to put the information in an array based on the following Jquery Codes.

 var slot_allocation= []; //array storing info
 $.getJSON('slot_allocations', function(data) { //get json method, put the items in the slot_allocation array.
    $.each(data, function(i, item) {
    slot_allocation.push(item);
 });

 //some extra methods for table creation etc.
 createSubjectsTable($("#subjects"),timeslots,subjects);
 makeDraggable();
 });

I would appreciate any help on which JQuery methods I could look into or what areas of my code I could change in order to update the model. Thanks in advance.

Additional codes as requested. The whole code is pretty lengthy though. This is the part where after dropping it, the model should be updated. My attempt at updating the array is the codes after the comment.

$('.Empty').droppable({
  accept: '.Group',
  tolerance: 'pointer',
  drop: function(event,ui){
    ui.droppable = $(this);
    var new_alloc_info = ui.droppable.attr("id")
    var array = new_alloc_info.split('--');
    var timeslot = array[1];
    var subject = array[2];

    var old_alloc_id = ui.draggable.attr("id");
    var array2 = old_alloc_id.split('--');
    var alloc_id = array2[3];

//This is the part where I want to update the rails model
    slot_allocation[alloc_id-1].timeslot=timeslot; 
    slot_allocation[alloc_id-1].subject=subject;        

    var allocText = "alloc--"+timeslot+"--"+subject+"--"+alloc_id;
    ui.draggable.attr("id",allocText);
    ui.draggable.insertBefore(ui.droppable);

  }
})
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T13:11:52+00:00Added an answer on June 16, 2026 at 1:11 pm

    OK. Within the drop callback you can make an AJAX request to server. WIthout trying to figure out what all your arrays are will start with simple case

    /* receive id and time params at server as you would form field "name" */ 
    var dataToServer={ id: alloc_id, time: timeslot};
    
    /* can use $.get or */
    $.post( url, dataToServer, function( response){
        /* AJAX completed successfully, can access response data here*/
    }/* dataType argument here if want to use JSON or XML response*/)
    

    Both $.post and $.get are shortcut methods of $.ajax which has many options available depending on needs

    jQuery AJAX API: http://api.jquery.com/category/ajax/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently implementing a HTML canvas based webapp that features panning. Is there a
I'm currently implementing a hash table in C++ and I'm trying to make a
I am currently implementing something quite similar to checkers. So, I have this table
I'm currently implementing a non-renewable in-app purchase and am a little concerned over the
I'm currently implementing a JavaScript library that keeps track of the history of changes
I'm currently implementing a very complex tree structure to allow for near-instant data access,
We are currently implementing MOSS 2007 to replace an older portal system (Plumtree) and
I'm currently implementing a .NET wrapper for a Java library by using JNI to
I'm currently implementing a RESTful API (nothing serious, just for a blog engine i'm
i am currently implementing a binary tree in c++ and i want to traverse

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.