i am having a problem with my rails 3 app
In my view i have
<%= button_to("Accept Post", {}, {:confirm => "Are you sure?", :method => :accept_question, :remote => true}) %>
The generated html is
<form method="post" action="/questions/show/1" data-remote="true" class="button_to">
<div>
<input data-confirm="Are you sure?" type="submit" value="Accept Post" />
<input name="authenticity_token" type="hidden" value="Rv1CbqkE+61Fn4wb836eOENjyGkNpzzRrwMTywLZPf0=" />
</div>
</form>
my gem file is loading this
gem 'jquery-rails'
The following .js files are appearing in the generated html
<script src="/javascripts/jquery.js?1309961714" type="text/javascript"></script>
<script src="/javascripts/jquery-ui.js?1309961714" type="text/javascript"></script>
<script src="/javascripts/jquery-ui.min.js?1305044364" type="text/javascript"></script>
<script src="/javascripts/jquery.min.js?1309961714" type="text/javascript"></script>
<script src="/javascripts/jquery.tools.min.js?1309338309" type="text/javascript"> </scipt>
<script src="/javascripts/rails.js?1309961714" type="text/javascript"></script>
<script src="/javascripts/application.js?1309424326" type="text/javascript"></script>
I have seen other posts on this topic, but nothing works, i get no error, just a redirect to the same page, without being prompted. I have other bits of code that use jquery, which work fine. the problem i have is that the confirm and method does not prompt be before continuing. What is a good way to implement jquery into an app, i have tried to include jrails, however all my other code breaks thanks for the help
I've seen this problem before, and I just found a workaround, using pure JavaScript. If you are in a hurry this might just do for now.
You can try this and you get the same effect:
<%= button_to("Accept Post", {}, {:onclick => "return confirm('Are you sure?')", :method => :accept_question, :remote => true}) %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With