Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] - prompt #172

Closed
wants to merge 5 commits into from
Closed

[FEATURE] - prompt #172

wants to merge 5 commits into from

Conversation

mkoczka
Copy link
Contributor

@mkoczka mkoczka commented Oct 29, 2014

Here is my pull request of prompt feature. Requested in #155

I also updated example website with documentation.

Here is live example - http://mirokoczka.eu/sweetalert/example

This was referenced Oct 29, 2014
@zuofei
Copy link

zuofei commented Oct 30, 2014

Well done! But can you add "Cancel" option for the Prompt box as well?

@mkoczka
Copy link
Contributor Author

mkoczka commented Oct 30, 2014

@zuofei Of course, you can add option showCancelButton: true.

Example:

swal({
    type: "prompt",
    title: "Prompt!",
    text: "Enter your text here:",
    showCancelButton: true,
    promptPlaceholder: "Your text goes here...",
    promptDefaultValue: "Some sweet default value"
}, function(value) {
    swal("Here's a message!", "Your prompt was: " + value, "success");
});

@zuofei
Copy link

zuofei commented Oct 30, 2014

@mkoczka

Got it. Thank you!

$okButton = modal.querySelector('button.confirm');

//prompt
var $promptInput = modal.querySelector('.prompt-input');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an exact dupe of line 679.

@parterburn
Copy link

Passing in imageSize does not work. The fix is to remove the following, because it's already being set right outside the if/else:

$customIcon.css({
  'width': imgWidth + 'px',
  'height': imgHeight + 'px'
});

Also, if you specify an imageUrl, it currently shows both the Prompt icon and the custom image. To hide the prompt icon you need to add the following right below if(params.imageUrl) {

var $icons = modal.querySelectorAll('.icon');
hide($icons);

@mkoczka
Copy link
Contributor Author

mkoczka commented Nov 5, 2014

@parterburn These are not issues related to prompt feature. I created another issue which address this problem here - #190

@jobsamuel
Copy link

I like this feature! But... why the alert appears twice? I mean, it isn't like warning: you press Yes, delete it and the modal changes its markup almost instantly. However, when you press Ok using prompt, the modal disappears and then comes back. That isn't sweet 😞

@mkoczka
Copy link
Contributor Author

mkoczka commented Nov 6, 2014

@jobsamuel It's just example. You don't need to use another alert in callback. You can do anything you want after prompt is confirmed.

@jobsamuel
Copy link

Now I see @mkoczka! Thanks for the clarification 👍

@eric-sal
Copy link

Pressing spacebar while typing in the prompt input submits the confirmation. These changes fixed that for me.

@hszcg
Copy link

hszcg commented Nov 24, 2014

Great feature, i like it a lot!

@t4t5
Copy link
Owner

t4t5 commented Jan 19, 2015

Due to popular demand, I have actively started looking into integrating this in a future release. I want to make some changes though so you're going to have to wait just a little longer. Just letting you guys know. Thanks so much for the contributions! :)

@lvillani
Copy link

Any update on this issue? We are using sweetAlert but are investigating vex to add custom prompts to our app but found some problems. Since both libraries lack the features we need we might as well help getting this feature into sweetAlert.

@craigsheen
Copy link

I think this is being worked on in this PR: #90

@lvillani
Copy link

Oh, thanks for pointing me in the right direction!

@manan-jadhav
Copy link

👍 I wanted this feature. This will now become a replacement for bootstrap modals also.

@t4t5
Copy link
Owner

t4t5 commented Mar 19, 2015

This has finally landed in v0.5.0 (although with a different implementation)! Download the latest release and follow the last part of this tutorial to get started: https://www.ludu.co/lesson/how-to-use-sweetalert.

Thanks everyone for your suggestions! Keep it sweet!

@t4t5 t4t5 closed this Mar 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants