I am trying to make my own confirm dialogs with two parameters.
function myAlert(message, adr) {
jConfirm(message, 'Confirmation Dialog', function(answer) {
if (answer){
window.location = adr;
}
});
}
$(document).ready(function() {
$.rails.confirm = function(mess, mess2) {
return myAlert(mess, mess2);
}
});
And in view:
<%= link_to 'Delete',
{:controller => 'controller_name', :action => 'action_name'},
:confirm => {"xxxxxxx", "aaaaaaaa"} %>
And in alert message I will get following:
xxxxxxxaaaaaaaa
What I am doing wrong? Why I don’t get only xxxxxxx? Why are the strings merged?
PS: the first parameter in jConfirm function display the message to confirm window.
I believe
:confirmis a string argument only. I’m a bit surprised, because:confirm => {"xxxxxxx", "aaaaaaaa"}should throw a syntax error if I’m not mistaken.If you want to pass two parameters, you could store them in separate data attributes and roll your own confirmation method, something like this:
Or you comma-separate your arguments and split them using JS: