Monday, November 18, 2024
Google search engine
HomeLanguagesJavascriptscript.aculo.us InPlaceEditor loadingText Option

script.aculo.us InPlaceEditor loadingText Option

The script.aculo.us library is a cross-browser library that aims at 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 loadingText option is used to specify the text that would be shown when the loadTextURL option is specified and the InPlaceEditor is loading text from the server. The default value when this option is not specified is “Loading…”.

Syntax:

{ loadingText: string }

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

  • string: This is a string that specifies the text to be used. The default value is “Loading…”.

The below example illustrates the use of this option.

Example:

The below HTML file demonstrates this with the example:

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',
        {
            
          // Script for loading the text
          loadTextURL: 
          'http://localhost/loadText.php',
  
          // Specify the text to be used while loading
          loadingText: 'Text loading from server!'
        }
      );
    }
  </script>
</head>
<body>
  <h1 style="color: green">
    neveropen
  </h1>
  <h2>InPlaceEditor loadingText Option</h2>
    
<p>The "loadingText" option specifies the placeholder
    text to be used when text is being loaded from the 
    server specified using the "loadTextURL" option.</p>
  
  <div id="editableElement">
    This is the editable element!
  </div>
</body>
</html>


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

PHP




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


The below loadText.php script 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:

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments