<%= submit_tag ‘Create’, :confirm => “Are you sure you would like #{@deposit} dibits deposited?” %>
What if you do this:
<%= submit_tag ‘Create’, :confirm => “Are you sure you would like " + $(‘funding_transaction_deposit’).innerHTML() + " dibits deposited?” %>
compile error
/Users/chabgood/web_apps_svn_working/dibspace_unfuddle/r2/app/views/funding_transactions/_form.rhtml:15: syntax error, unexpected $undefined
... you sure you would like " + $('funding_transaction_deposit'...
> kinda hung here I have this and I am getting js in the popup.
> <%= @deposit = javascript_tag "$('funding_transaction_deposit').innerHTML"
> %>
> <p>
> <%= submit_tag 'Create', :confirm => "Are you sure you would like
> #{@deposit} dibits deposited?" %>
> </p>
What if you do this:
<%= submit_tag 'Create', :confirm => "Are you sure you would like " +
$('funding_transaction_deposit').innerHTML() + " dibits deposited?" %>
Submit tag is probably going to escape any attempt at including actual
javascript in the confirm text (I'd consider it a bug if it didn't).
You're probably going to need to craft the button's onclick by hand
(You could look at the autogenerated javascript and then replace the
confirm message with something similar to what David suggested.
The simplest way to do the return true/false stuff is:
<form action="foo" method="post" onsubmit="return confirm('Are you sure?');">
...
The return false (which happens if the confirm is cancelled) stops the form submission directly. I imagine you could do the same with your onclick event on the button, but putting it in the form submission makes it pretty foolproof, since the button might not be clicked (someone types Enter and the form submits without a click).
Actually what I posted is what rails produces, I copied the javascript from the page source. I was more interested how to get the div id value into the string, is it a quote issue?
Actually what I posted is what rails produces, I copied the javascript from the page source. I was more interested how to get the div id value into the string, is it a quote issue?
For what? unless you quote the relevant part of the original email and put your responses inline anyone who happens to stumble into the middle of your issue is unlikely to be able to help.