I have an edit account button on each row of a table that makes the table editable. Above each row there are different messages that need to be display. I'd like to pass the different messages with a data attribute on each link. But currently the data attribute only is used as a string. Not to change the different messages. See jQuery below...
var editAccount = $(".accounts_edit");
editAccount.click(function(e) {
e.preventDefault();
var origHTML = $(this).parents("tr").html();
var newAccountMsg = "<p>A new account was added by your bank adminstrator. To make payments from the account please link it to your bank account by entering the account number.</p>"
var authPaymentsMsg = "<p>Contact your <a href=\"#\">bank adminstrator</a> who can authorize payments from this account. This is a security feature.</p>"
var acctSystemMsg = "<p class=\"error_msg\">This account was retrieved from your accounting system. To make payments from this account, please link it to your bank account by entering your account number.</p>"
var whatMessage = $(this).data("msg");
console.log(whatMessage);
var editHTML = "<tr class=\"accounts_message\">" +
"<td class=\"accounts_primary\"></td>" +
"<td colspan=\"5\">" + whatMessage + "</td>" +
"</tr>" +
"<tr class=\"accounts_edit\">" +
"<td></td>" +
"<td><input type=\"text\" class=\"new_account_no\" required=\"required\" /></td>" +
"<td><input type=\"text\" class=\"new_account_name\" required=\"required\" /></td>" +
"<td><input type=\"text\" class=\"new_starting_check\" required=\"required\" /></td>" +
"<td class=\"accounts_enable_ach\">Yes</td>" +
"<td class=\"accounts_manage\">" +
"<a class=\"btn btn-custom\" href=\"#\">Save</a><a class=\"btn\" href=\"#\">Cancel</a>" +
"</td>" +
"</tr>";
$(this).parents("tr").replaceWith(editHTML);
});
Please let me know how var whatMessage can call the different messages and not simply print the data string. Thanks!