Reputation: 1
I am using jConfirm to create a popup. I want it to display the message "Are you sure?" and the title "Confirm Deletion." The title works fine, and the callback works fine. But the message is displayed as [object Object]
, and I cannot figure out why. I'm specifying a string as the message, so it shouldn't be getting confused.
This is the javascript generated by Rails:
<a onclick="deletePaymentMethod('3', 'gateway_bogus_3');" href="#"><img src="/assets/theme/admin/icons/delete.png" alt="Delete"> Delete</a>
And this the function in question:
function deletePaymentMethod(method, dom_id) {
jConfirm('Are you sure?', 'Confirm Deletion', function(r) {
if(r){
jQuery.ajax({
type: 'DELETE',
url: '/admin/payment_methods/' + method,
data: ({_method: 'delete', authenticity_token: AUTH_TOKEN}),
success: function(r){ $('#'+dom_id).fadeOut(); }
});
}
});
}
jConfirm is defined in jquery.alerts.js (https://github.com/caricorrejidor/jquery-alerts) as:
function(message, title, callback)
Additionally, I use jConfirm elsewhere in my codebase, and it works as expected.
ETA: I ended up just tweaking these lines in the library:
$("#popup_message").text(msg);
$("#popup_message").html( ("" + $("#popup_message").text()).replace(/\n/g, '<br />') );
I replaced it with this, and now everything is swell:
$("#popup_message").html( msg.replace(/\n/g, '<br />') );
Upvotes: 0
Views: 75