Skip to content
Related Articles

Related Articles

script.aculo.us InPlaceEditor loadTextURL Option
  • Last Updated : 27 Nov, 2020

The script.aculo.us library is a cross-browser library that aims to improving the user interface of a website. The Ajax.InPlaceEditor is used to make elements editable thereby allowing the user to edit the content on the page and submit the changes to the server.

The InPlaceEditor loadTextURL option is used to specify the URL of the server from where the text would be loaded when the editable element is interacted upon. This is useful when the text on the server is formatted and required to be loaded in the editable element.

Syntax:

{ loadTextURL: URL }

Value: This option has a single value as mentioned above and described below:

  • URL: This is a string that specifies the URL to be used for loading the text. The default value is null.

The below example illustrates the use of this option.



Example: The example demonstrates the InPlaceEditor loadTextURL option.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <script type="text/javascript" 
        src="prototype.js">
    </script>
  
    <script type="text/javascript" 
        src="scriptaculous.js?load = controls">
    </script>
  
    <script type="text/javascript">
        window.onload = function () {
            new Ajax.InPlaceEditor(
                'editableElement',
  
                // Script for the functioning
                // of the editor
                'http://localhost/inplace.php',
                {
  
                    // Specify the script from 
                    // where the text would be 
                    // loadec
                    loadTextURL:
                    'http://localhost/loadText.php',
                }
            );
        }
    </script>
</head>
  
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
  
    <h2>InPlaceEditor loadTextURL Option</h2>
  
  
    <p>
        The "loadTextURL" option is used to 
        specify the URL of the server from 
        where the text would be loaded when 
        the editable element is interacted 
        upon.
    </p>
  
    <div id="editableElement">
        Click this element to edit it!
    </div>
</body>
  
</html>

The file inplace.php is required to simulate the saving of data to the server.

PHP




<?php
  if( isset($_REQUEST["value"]) ) {
    $str = $_REQUEST["value"];
    echo $str;
  }
?>

The file loadText.php is required to simulate the server from where the text would be loaded.

PHP




<?php
  
  // Sleep is used to simulate the delay of
  // the server request 
  sleep(1);
  
  echo "This is the text from the server!";
?>

Output:

My Personal Notes arrow_drop_up
Recommended Articles
Page :