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

  • Home
  • SEARCH
  • 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 4041340
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:52:06+00:00 2026-05-20T12:52:06+00:00

I have a few jQueryUI draggable objects that represent nodes generated on my front

  • 0

I have a few jQueryUI draggable objects that represent nodes generated on my front page in Drupal.

I want to grab when a user drops an element and save the x/y coordinates to the server so when the next user opens the page it will still be where it was last left at.

I created two integer fields, homex and homey, but I can’t seem to figure out or find enough documentation to learn how to tell Drupal to update the values for a given node.

I’m fairly familiar with how to create modules in Drupal, and ajax in general – but combining the two in this case is perplexing me.

Can someone help me understand how to attach to Drupal so I can save the coordinates dynamically?

What would be preferable is if I could just write a simple handler module for Drupal that takes the x/y pair in a get/post request then updates them in the database and responds with a success/json. Really if it wasn’t being done in Drupal this would be a fairly simple setup.

  • 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-05-20T12:52:06+00:00Added an answer on May 20, 2026 at 12:52 pm

    It seems all I had to do was create a hook_menu() and a hook_ajax_callback() (sorry couldn’t find a link) in a module.

    Here’s what I ended up with (more less, leaving in three different return methods I was playing with):

    <?php
    
    function homepage_coords_menu(){
        return array(//$items
            'homepage_coords/%node/%/%' => array(
                'page callback' => 'homepage_coords_ajax_callback',
                'page arguments' => array(1,2,3),
                'access callback' => TRUE,
                'type' => MENU_CALLBACK,
            )
        );
    }
    
    function homepage_coords_ajax_callback($node,$x=0,$y=0){    
        if(!is_numeric($x) || !is_numeric($y)){
            ajax_deliver(json_encode(array(
                'status'=>'fail'
            )));            
        }
    
        $node->field_homepagex = array('und'=>array(array('value'=>$x)));
        $node->field_homepagey = array('und'=>array(array('value'=>$y)));
    
        node_save($node);
    
        ajax_deliver(json_encode(array(
            'status'=>'win'
        )));
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a few Visual Studio Solutions/Projects that are being worked on in my
We have a few projects that involve building an application that is composed of
I have a few lines of PowerShell code that I would like to use
I want a Simple jquery plugin. i have looked at a few and even
I have a few view helpers that add JavaScript files when they're needed (for
I have few asynchronous tasks running and I need to wait until at least
I have few different applications among which I'd like to share a C# enum.
I'm a newbie to pgsql. I have few questionss on it: 1) I know
How do I create subdomains in ASP.NET? I have few links on my homepage(Home.aspx)
We have a few very large Excel workbooks (dozens of tabs, over a MB

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.