📌  相关文章
📜  script.aculo.us InPlaceEditor cancelLink 选项(1)

📅  最后修改于: 2023-12-03 15:20:01.378000             🧑  作者: Mango

script.aculo.us InPlaceEditor cancelLink 选项

The cancelLink option in script.aculo.us InPlaceEditor provides developers with the ability to customize the cancel button in the InPlaceEditor widget. This option allows customization of the cancel button's appearance, behavior, and associated events.

Syntax
new Ajax.InPlaceEditor(element, url, options);
Usage

The cancelLink option accepts different values to customize the cancel button:

  1. Boolean value: By default, if cancelLink is set to true, a cancel link will be displayed next to the input field, allowing users to cancel the editing process. If set to false, the cancel link will not be displayed. Example:

    new Ajax.InPlaceEditor('myElement', '/url', {
      cancelLink: true
    });
    
  2. String value: You can provide a custom string that will be used as the text for the cancel link. Example:

    new Ajax.InPlaceEditor('myElement', '/url', {
      cancelLink: 'Cancel Edit'
    });
    
  3. Element value: Instead of a string, you can also pass an HTML element that will be used as the cancel link. Example:

    new Ajax.InPlaceEditor('myElement', '/url', {
      cancelLink: $('myCancelLink')
    });
    
Events

The cancel link supports the following events:

  • cancel: This event is triggered when the cancel link is clicked. It can be used to perform additional actions or handle any necessary cleanup. Example:

    new Ajax.InPlaceEditor('myElement', '/url', {
      cancelLink: true,
      onBeforeCancel: function(Editor, newText, oldText){
        // Perform additional actions before cancelling
      },
      onCancel: function(Editor, newText, oldText){
        // Handle cancel event
      }
    });
    
Additional Options

In addition to the cancelLink option, the InPlaceEditor widget also provides other options to further customize its behavior:

  • okLink: Customizes the OK button.
  • onComplete: Event triggered after editing is completed.
  • onFailure: Event triggered when the AJAX request fails.
  • clickToEditText: Text displayed when the element is clicked to start editing.

For more information on these options, you can refer to the script.aculo.us documentation.

Note: The InPlaceEditor widget requires the script.aculo.us library to be included in your project.