Sweetalert: Preload value in sweet alert prompt

Created on 25 Mar 2015  Â·  13Comments  Â·  Source: t4t5/sweetalert

Most helpful comment

inputValue: "value here"

All 13 comments

?

First of all i must say the sweetalert prompt is a beautiful addition made
my ui much more subtle.Thanks and well done.

I'm trying to add an initial parameter in the prompt box like in
javascript's prompt.

E.g prompt('This is the prompt', 'Initial parameter in the prompt box ');

Looking forward to hearing back from you.

On Wed, Apr 1, 2015 at 11:57 AM, Tristan Edwards [email protected]
wrote:

?

—
Reply to this email directly or view it on GitHub
https://github.com/t4t5/sweetalert/issues/321#issuecomment-88439615.

I want this function, too. Thanks

+1 shouldn't be too hard to add :)

try

$('input').val(startValue);

using jQuery with your startValue after swal() call

Would be great if this could be added as a property in the swal() call.
For now I've got it working but I feels 'hacky':
Code:
jQuery('.sweet-alert input[type=text]:first' ).val('the val');

+1

+1

This is available in the latest version through inputValue: 'someValue'! :)

+1

inputValue: "value here"

inputValue: "value here"

This doesn't work for me

swal({
content: {
element: "input",
attributes: {
placeholder: "Type your password",
type: "password",
value: "Your value"
},
},
});

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GabrielSt picture GabrielSt  Â·  9Comments

adhip94 picture adhip94  Â·  8Comments

IvoPereira picture IvoPereira  Â·  14Comments

amiceli picture amiceli  Â·  19Comments

omaryoussef picture omaryoussef  Â·  20Comments