Saturday, November 15, 2025
HomeLanguagesJavascriptscript.aculo.us InPlaceEditor externalControl Option

script.aculo.us InPlaceEditor externalControl Option

In this article, we will demonstrate the effect of externalControl option of InPlaceEditor class by using a JavaScript library called script.aculo.us which helps us in adding an element which will trigger the editing of the in-place editor.

Syntax:

Ajax.InPlaceEditor( element, url, { size: 100 });

Approach 1: To demonstrate the use of this function, we have written a small piece of code. We have written a small JavaScript code which will create an in-place editor for specific elements. By clicking on the button, you will see the in-place editor is triggered and goes into edit mode.

Example: 

HTML




<!DOCTYPE html>
<html>
  
<head>
    <!-- Import the libraries -->
    <script type="text/javascript"
        src="prototype.js">
    </script>
  
    <script type="text/javascript"
        src="scriptaculous.js">
    </script>
</head>
  
<body>
    <p id="editme">Click me</p>
  
  
    <button id="editbutton">
        Edit
    </button>
      
    <!-- Script for the JavaScript
        to initialize the objects -->
    <script type="text/javascript">
        new Ajax.InPlaceEditor(
            'editme', 'example', 
            { externalControl: 'editbutton' }
        );
    </script>
</body>
  
</html>


Output:

Approach 2: In this approach, we have written a small JavaScript code which will create an in-place editor for specific elements, and then we will make a request to a file and fetch the content from that file. We will create a file with name test.html with a simple text neveropen in it. By clicking on the button, you will see the in-place editor is triggered and goes into edit mode we will click on OK to get the content from the file.

Example: 

HTML




<!DOCTYPE html>
<html>
  
<head>
    <!-- Import the libraries -->
    <script type="text/javascript" 
        src="prototype.js">
    </script>
  
    <script type="text/javascript" 
        src="scriptaculous.js">
    </script>
</head>
  
<body>
    <p id="editme">Click me</p>
  
  
    <button id="editbutton">
        Edit
    </button>
      
    <!-- Script to initialize the objects -->
    <script type="text/javascript">
        new Ajax.InPlaceEditor(
            'editme', '/test.html', 
            { externalControl: 'editbutton' }
        );
    </script>
</body>
  
</html>


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

Dominic
32399 POSTS0 COMMENTS
Milvus
95 POSTS0 COMMENTS
Nango Kala
6765 POSTS0 COMMENTS
Nicole Veronica
11917 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11984 POSTS0 COMMENTS
Shaida Kate Naidoo
6890 POSTS0 COMMENTS
Ted Musemwa
7143 POSTS0 COMMENTS
Thapelo Manthata
6838 POSTS0 COMMENTS
Umr Jansen
6840 POSTS0 COMMENTS