I am trying to clear a form once the info is being submitted to the
database. Basically what I have is a form that makes use of the
form_remote_tag which adds a list of credit cards to a list and then
adds that info to a database. What I want to happen is that once the
submit button is hit the form clears so that the user can enter another
credit card if they so choose. what I have tried is adding an :onclick
to my submit_tag helper:
to just clear the form, which it did. However, it cleared the form
before the POST so nothing got through to the database and an exception
was thrown. Anyone have any hints and how I could handle this. Thanks,
I am trying to clear a form once the info is being submitted to the
database. Basically what I have is a form that makes use of the
form_remote_tag which adds a list of credit cards to a list and then
adds that info to a database. What I want to happen is that once the
submit button is hit the form clears so that the user can enter another
credit card if they so choose. what I have tried is adding an :onclick
to my submit_tag helper:
to just clear the form, which it did. However, it cleared the form
before the POST so nothing got through to the database and an exception
was thrown. Anyone have any hints and how I could handle this. Thanks,
~S
Hello
Are you using rjs? If so, i think you can use
page[‘form_id’].reset
in your create.rjs
the raw html doesn’t show an id attirbute and thus my .rjs file does
nothing. Another thing is what do I call the .rjs file? If the file that
has the form is edit_form.rhtml should I name my rjs file edit_form.rjs?
I’m just a little confused on how the code in the .rjs file get excuted.
Thanks,
Im not sure what’s going on. I have a web apps book for Ruby on Rails
which describes the same things that you have been suggesting as far as
the .rjs file goes but it is not working. I have matched the method name
with the .rjs file and have given all the html elements the proper id’s,
but it’s still not working. I don’t think it is excuting the .rjs file,
but I don’t see why. I’ll keep messing with. Thanks for your help. It’s
all about learning new things and I have learned a lot even if it’s not
cooperating.
the raw html doesn’t show an id attirbute and thus my .rjs file does
nothing. Another thing is what do I call the .rjs file? If the file that
has the form is edit_form.rhtml should I name my rjs file edit_form.rjs?
I’m just a little confused on how the code in the .rjs file get excuted.
Thanks,
The problem taht I had before was that I was using this exact same
JavaScript to clear the form, but it cleared it before it posted the
info, making is usless, plus it crashed on top of that. I imagine what
:complete does is post first then execute the JavaScript. But that’s how
I got it to work, now I’m going on break!
~Shandy
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.