JqInlineEdit is a very simple and lightweight Html inline editing plugin that allows you to edit any inline text using an input field, select box or textarea. When triggered on a specific element it will converts to input, select or textarea where you can edit the text and after editing the text it will revert to its previous state.
1. Include the jQuery inline-edit.jquery.js
at the bottom of the web page.
<script src="path/to/inline-edit.jquery.js"></script>
2. Add the basic HTML to the page.
<span class="input"><button class="btn btn-success">Click me to edit</button></span>
3. Initialize the plugin and we're ready to go.
$(".input").inlineEdit({
type: 'text',
onChange: function (e, text, html) {
// Executes when exiting inline edit mode and a change has been made
},
onEdit: function (e) {
// Executes when entering inline edit mode
},
onNoChange: function (e) {
// Executes when exiting inline edit mode but no change has been made
}
});
Property | Type | Options | Default | Description |
---|---|---|---|---|
type | string | text, select, textarea | text | The type of value the clicked text will turn into. |
className | string | null | A custom class to add to the created inline edit element. | |
on | string | Any jQuery trigger
[click, dblclick, etc.] |
click | This is how the inline edit will be triggered |
customData | object | null | Custom properties to add to the inline edit tag | |
data | object | null | Options for the select as a key:value object | |
trim | bool | true/false | true | Trim whitespace around text before loading into the text input or textarea |
Method | Values | Description |
---|---|---|
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 |
Event | Description |
---|---|
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 |
<span class="input"><button class="btn btn-success">Click me to edit</button></span>
$(".input").inlineEdit({
type: 'text',
});
<span class="textarea"><button class="btn btn-success">Click me to edit</button></span>
$(".textarea").inlineEdit({
type: 'textarea',
});
<span class="select"><button class="btn btn-success">Click me to edit</button></span>
$(".select").inlineEdit({
type: 'select',
data: {
'default': 'Click me to edit',
'opt-1': 'jQuery',
'opt-2': 'Script'
}
});
<span class="paragraph">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</span>
$(".paragraph").inlineEdit({
type: 'text',
});