Pre-fill default text in prompt mode
Is it possible to pre-fill a default text for the input in the prompt mode? (just what the javascript native prompt 2nd parameter does).
Not currently, but good idea. It would be easy to add as another option in the show method, which would get passed through this prompt options.
A bonus option would be a way to specify text selection too (e.g. if you’re renaming a file and only want to select the file name, not extension).
I'd say, that if a defaultValue for the prompt input is defined in the options, it should be directly .select() instead of .focus()
This actually can be done by altering the default "prompt" option, like this:
$.alertable.prompt('Change price to:', {
html: true,
prompt: '<input class="alertable-input" type="text" name="value" value="' + currentprice + '">',
okButton: '<button class="alertable-ok" type="submit">Continue</button>',
cancelButton: '<button class="alertable-cancel" type="button">Cancel</button>'
}).then(function(data) {
var new_price = data['value'];
});