项目作者: faulker

项目描述 :
jQuery Inline Edit
高级语言: HTML
项目地址: git://github.com/faulker/jqInlineEdit.git
创建时间: 2018-06-22T17:11:31Z
项目社区:https://github.com/faulker/jqInlineEdit

开源协议:MIT License

下载


jQuery Inline Edit Plugin

A small javascript library built on top of jQuery that allows you to easily do inline text editing using a text input, select, or textarea.


Usage

Load the plugin

  1. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.31/jquery.min.js"></script>
  2. <script src="inline-edit.jquery.js"></script>

HTML

  1. <span id="example-text"><button class="btn btn-success">Click Me</button></span>

JavaScript

  1. $("#example-text").inlineEdit({
  2. type: 'text',
  3. onChange: function (e, text, html) {
  4. // Executes when exiting inline edit mode and a change has been made
  5. },
  6. onEdit: function (e) {
  7. // Executes when entering inline edit mode
  8. },
  9. onNoChange: function (e) {
  10. // Executes when exiting inline edit mode but no change has been made
  11. }
  12. });

Properties

  • type (text, select, textarea) - The type of value the clicked text will turn into.
  • className - A custom class to add to the created inline edit element.
  • on (click, dblclick, etc.) - This is how the inline edit will be triggered
  • customData - Custom properties to add to the inline edit tag
  • data - Options for the select as a key:value object
  • trim (true/false) - Trim whitespace around text before loading into the text input or textarea

Methods

  • onChange(this, text, html) - Executes when exiting inline edit mode and a change has been made
  • onEdit(this) - Executes when entering inline edit mode
  • onNoChange(this) - Executes when exiting inline edit mode but no change has been made

Events

  • inlineEdit.on.edit - Fires when exiting inline edit mode and a change has been made
  • inlineEdit.on.change - Fires when entering inline edit mode
  • inlineEdit.on.noChange - Fires when exiting inline edit mode but no change has been made