trentrichardson / jQuery-Impromptu

An extention to help provide a more pleasant way to spontaneously prompt a user for input.
http://trentrichardson.com/Impromptu/
MIT License
327 stars 144 forks source link

Submitted form values are lost when applying bootstrap style. #34

Closed topless closed 10 years ago

topless commented 10 years ago

When the state html property is defined like suggested in the documentation, the form passes the values properly.

html: '<label>First <input type="text" name="fname" value=""></label><br />'+
      <label>Last <input type="text" name="lname" value=""></label><br />',

But when I am using the html layout that bootstrap requires to look nice, like

html: '<form class="form-horizontal" role="form">
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">Email</label>
    <div class="col-sm-10">
      <input type="email" class="form-control" id="inputEmail3" placeholder="Email">
    </div>
  </div>
</form>',

my form values are lost and I get an empty object as a result.

trentrichardson commented 10 years ago

There is already a form generated by impromptu, so you're ending up with a form inside a form, so this causes impromptu's form to not have any values.

trentrichardson commented 10 years ago

The posted commit is to the dev branch, it adds an option for classes to be appended to impromptu's generated form, so you would do something like:

$.prompt('test message', { 
    classes: { 
        form: 'form-horizontal'
    } 
});

You can do other elements like this too when you need to add some extra styling, have a look at the docs or source around line 212 for all the options for "classes"

topless commented 10 years ago

Thanks a lot, that works as expected, I should have been more thorough in first place :)