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 6468469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:53:33+00:00 2026-05-25T05:53:33+00:00

I have a function to save the new position of a draggable div created

  • 0

I have a function to save the new position of a draggable div created dynamically.

<script type="text/javascript"> 

  $(document).ready(function() {

    $(".comdiv").draggable(

    {

      drag: function(event, ui) {

        $(".comdiv").css("opacity", "0.6"); // Semi-transparent when dragging

      },

      stop: function(event, ui) {

       alert ('Finished dragging!');

        $(".comdiv").css("opacity", "1.0"); // Full opacity when stopped

      },

    });

  });

</script> 

This works for a static div defined in the body of the HTML page. I get the alert box. But I also create divs in a php script called through ajax. The alert box doesn’t come up for these. The event handler is defined for the entire class. Is there a different way of calling that function for the divs created in this script? The alert box doesn’t come up for them.

<?php

function get_nodes() {
// load SimpleXML
$nodes = new SimpleXMLElement('communities.xml', null, true);

foreach($nodes as $node) // loop through 
{

        echo "<div id = '".$node['ID']."' class= 'comdiv ui-widget-content' style = 'top: ".$node->TOP."px; left: ".$node->LEFT."px; 

width: ".$node->WIDTH."px; height: ".$node->HEIGHT."px;'> \n";

        echo "   <p class = 'comhdr editableText ui-widget-header'>".$node->NAME."</p>\n";

        echo "   <a href='#' onClick=\"delete_div('".$node['ID']."');\">Delete</a>&nbsp;&nbsp;\n";
        echo "   <a href='#' onClick=\"add_url('".$node['ID']."');\">Add URL</a>&nbsp;&nbsp;\n";

        foreach($node->URLS->URL as $url)
        { 
           echo "   <div id='".$url['ID']."' class='comurl'><a href='".$url->URLC."' target='_blank'>".$url->NAME."</a><img 

align='right' src='redx.png' onClick='delete_url(\'".$url['ID']."\');'/></div>";

           /* echo "<script type='text/javascript'> alert('Node: ".$node['ID']." has URLS:".$url['ID']." ".$url->NAME." ".$url->URLC." 

'); </script>"; */
        }

        echo "</div> \n";

        echo "<script type='text/javascript'>\n";
        echo "  $('#".$node['ID']."').resizable();\n";
        echo "  $('#".$node['ID']."').draggable();\n";
        echo "  $('#".$node['ID']."').draggable('option', 'handle', '.comhdr');\n";
        echo "</script>\n";

}
        echo "<script type='text/javascript'>\n";
        echo "  $('.editableText').editableText();\n";
        echo "</script>\n";

   return;
}

echo get_nodes();

?>

Here is the HTML.

<body>

<div style="top:450px; width:120px; height:120px; left:800px; background:red;"></div>

<!-- THE ALERT BOX COMES UP IF I DRAG THIS DIV -->
<div id="editdiv" class="comdiv ui-widget-content" style="position: absolute; top: 150px; left: 850px; width:350px; height:250px; border:1px solid grey;">
    <p id="heading" class="comhdr editableText ui-widget-header">Editable</p>
</div>

<script type="text/javascript">

 $(document).ready(function() {
               //define php info and make ajax call to recreate divs from XML data
               $.ajax({
                   url: "get_nodes.php",
                   type: "POST",
                   data: { },
                   cache: false,
                   success: function (response) {

                       if (response != '') 
                       {
                          $(document.body).append(response);

                       }
                   }
               });
 });

</script>

<script type="text/javascript"> 

  $(document).ready(function() {

    $(".comdiv").draggable(

    {

      drag: function(event, ui) {

        $(".comdiv").css("opacity", "0.6"); // Semi-transparent when dragging

      },

      stop: function(event, ui) {

       alert ('Finished dragging!');

        $(".comdiv").css("opacity", "1.0"); // Full opacity when stopped

      },

    });

  });

</script> 

</body>
</html>
  • 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-25T05:53:34+00:00Added an answer on May 25, 2026 at 5:53 am

    The permissions needed to be set on the folder containing the XML along with the xml itself. Did that for owner, system, iis user, and user.

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

Sidebar

Related Questions

I have the following code: <script type=text/javascript> $(document).ready(function() { $(#Save).click(function() { $.post(url, { data:
First i have declare that i am new to javascript. I have created a
I have a function that dynamically adds text to an image in a predesignated
i have the following function to override the default save function in a model
I have code that uses Win API function RegSaveKeyEx to save registry entries to
I have a btnSave_Click() function in my code-behind. If a user clicks the save
I have a simple unsubscribe function in my Unsubscribed controller. if ($this->Unsubscribe->save($this->data['Unsubscribes'])) { //
I have a save function for my order entity that looks like this and
i have a class like this: class myclass { public function save($params){ // some
I want to save my canvas into MySQL database (BLOB cell). I have function

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.