OptionalcancelThe text displayed on Cancel button.
OptionalcancelThe classes added to Cancel button.
OptionaldebugEnabling debug mode will produce verbose output in the console.
OptionaleventThis is where you define the type of event that will trigger malle.
OptionalfocusShould the newly created input grab focus?
OptionalformThe classes added to the form element.
OptionalinputThe classes added to the input element.
OptionalinputDefine the type of the input element.
OptionalinputAllow setting a different value than the current element content.
OptionallistenStart listening immediatly or not.
OptionallistenHTML selector to target malleable elements on the page.
OptionalonWhat Action should be taken when focus of the input is lost.
OptionalonWhat Action should be taken when the Enter key is pressed?
OptionalonWhat Action should be taken when the Escape key is pressed?
OptionalplaceholderA text that is shown on empty input.
OptionalrequireDo nothing if new value is the same as the old value.
OptionalreturnedUse innerHTML instead of innerText (only use if the return value is trusted HTML).
OptionalselectAn array of options for InputType.Select. Can also be a Promise and fetched asynchronously.
OptionalselectWhat is the name of the key to use to lookup the option text in the selectOptions array?
OptionalselectWhat is the name of the key to use to lookup the values in the selectOptions array?
OptionalsubmitThe text on the Submit button.
OptionalsubmitThe classes added to the submit button.
OptionaltooltipThe text added on hover of the malleable element. Uses the title attribute.
OptionalafterFunction to execute after all the other events.
OptionalbeforeThis function will be called before anything else is done, once the trigger event has been fired.
If it returns something else than true, the edition will be canceled.
This is the main and only mandatory option parameter. It is the user function that is called when the Submit action happens.
// this is the user function that will process the new value
// typically this will POST to some endpoint and get some json back
// it receives the event
const myCustomFunction = (value, orig) => {
console.log(`New text: ${value}`);
// do something with that value, like POSTing it somewhere
return new Promise(resolve => resolve(value));
};
new Malle({
fun: myCustomFunction,
}).listen();
OptionalonA function that runs when a Cancel action is performed. Must return true or the input is not reverted to the original element.
OptionalonThis function runs right after the form is created. Its return value has no impact.
Configuration object for the Malle class.