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 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 an array set inside a velocity template that contains some paths. The
I have my screen divided into two DIV s. In the left DIV I
I am currently working on a project where I need to go for draggable
I have a form split apart throughout 4 tabs. One of the tabs contains
What percentage of browsers would probably have Google's cached version of JQuery already loaded?
I have a link: <a class=fg-button ui-state-default fg-button-icon-left assistButton pbcType=download title=Click for download information><span
I've got a membership site using the default ASP.NET membership setup. The user accounts
I've recently inherited the maintenance of a big, ugly codebase for a production website.
I'm wondering how one can catch and add a custom handler when empty results
Given a set of typical models: # Application A from django.db import models class

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.