Charlie Charlie - 1 month ago 4
jQuery Question

jquery select from inserted html

having trouble selecting from inserted modal html. dispatchBody won't' select or insert

success: function (response) {
var result = omac.getJson(response);
if (result.status.msg == "Success.") {var html = '<div class=\"modal right fade\" id=\"referenceModel\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"myModalLabel\"> <div class=\"modal-dialog\" role=\"document\"> <div class=\"modal-content\"> <div class=\"modal-header\" style=\"background-color: #428bca;color:#fff;\"> <button type=\"button\" class=\"close\" id=\"btnCloseModel\" data-dismiss=\"modal\" aria-label=\"Close\"><span aria-hidden=\"true\">&times;<\/span><\/button> <h4 class=\"modal-title\" id=\"myModalLabel\">Reference Center<\/h4> <\/div> <div class=\"modal-body dispatchBody\"> <\/div> <div class=\"modal-footer\"> <button type=\"button\" class=\"btn btn-primary\" data-dismiss=\"modal\">CLOSE<\/button><\/div><\/div><\/div><\/div>';
$(html).after(".mainBody");
$('.dispatchBody').html(result.results.html);
}}

Answer

My guess as to what you are trying to do here is: insert the contents of var html after .mainBody, and set the content of .dispatchBody to the returned result

Which leaves you with an incorrect use of .after, it should be

$(".mainBody").after(html);

see http://api.jquery.com/after/ for details on after

If that is not your intent, update you question to reflect that.

Comments