-
Notifications
You must be signed in to change notification settings - Fork 144
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
How can I open a prompt in a certain state? #61
Comments
Hey @uusijani This is a very good question, and I there actually isn't directly a way to do this outside of making the first state in your array the one you open first. I can definitely see this being an option like "initialState" or something. This would take place around line 369 in the src folder: var $firstState = t.jqi.find('.'+ opts.prefix +'states .'+ opts.prefix +'state').eq(0);
t.goToState($firstState.data('jqi-name')); So we might could change it to either look for a string for state name, or number for index (the current method) t.goToState(
isNaN(opts.initialState) ? opts.initialState :
t.jqi.find('.'+ opts.prefix +'states .'+ opts.prefix +'state').eq(opts.initialState).data('jqi-name')
); The option would also need to be added the the defaults object and default to 0. You would then call it like: $.prompt(states, { initialState: 'my-state-name' }); I will try to update the dev branch with this as I it would be a great addition. Thanks! |
Hey @trentrichardson, and thanks for the response! The best I could figure in the meantime was to initialize the prompt differently in each branch, like so:
But it's definitely better to have true support for this in the extension itself. Excellent! |
@uusijani This was the first change to the dev branch since the last stable release, so it should be pretty stable if this change works. This change is located in the dev branch: https://github.com/trentrichardson/jQuery-Impromptu/tree/dev |
@trentrichardson I've just tested the branch with the change and it's working perfectly. |
Sorry if this is obvious, but how can I open a multiple-state prompt in a specific state other than the first one in the states object? In other words, in the first statesdemo example, how can I open the prompt in state1 instead of state0?
I'm working on a login/logout/registration form with each of the three as a separate state and would like to start the prompt in either the "log in" or "log out" state depending on whether the user is currently logged in or not.
(I'm trying to work out the solution reading Impromptu's source code, but figured I'd also pose this question here for others like me to find in the future.)
The text was updated successfully, but these errors were encountered: