Link to home
Start Free TrialLog in
Avatar of danielolorenz
danielolorenz

asked on

My JQuery Data Tables Did Not Load After Page Load?

On MVC when I try to table load JQuery DataTable on the page load it does not attach to my HTML table.

When I use the AJAX onComplete to trigger the JQuery table load it works fine.

My JQuery table load routine:
function onEMailNotificationsComplete() {
    alert("onEMailNotificationsComplete");
    $('#email-notifications-results table').dataTable({
        "bFilter": true,
        "bSort": true,
        "bLengthChange": false,
        "bPaginate": true,
        "sPaginationType": "full_numbers",
        "sDom": "<'row'<'col-md-6'i><'col-md-6'f>r>t<'row'<'col-md-6'i><'col-md-6'p>>",
        "bInfo": true
    });
}

HTML Table:
<table id="email-notifications-results" class="table table-bordered table-striped table-hover"> 
        <thead>
            <tr>
                <td>
                    <strong>Date E-Mail Sent</strong>
                </td>
                <td>
                    <strong>Applicant Id</strong>
                </td>
                <td>
                    <strong>Person Name</strong>
                </td>
                <td>
                    <strong>Background Check Results</strong>
                </td>
            </tr>
        </thead>
        <tbody>
            @foreach (var emailNotification in Model)
            {
                var dateEMailSent = emailNotification == null ? "" : emailNotification.DateEMailSent.ToShortDateString();

                <tr>
                    <td>
                        @Html.DisplayFor(model => dateEMailSent)
                    </td>
                    <td>
                        @Html.DisplayFor(model => emailNotification.ApplicantId)
                    </td>
                    <td>
                        @Html.DisplayFor(mode => emailNotification.PersonName)
                    </td>
                    <td>
                        @Html.DisplayFor(mode => emailNotification.BackgroundCheckResults)
                    </td>
                </tr>
            }
        </tbody>
    </table>

Open in new window


Thanks,

Dan
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of danielolorenz
danielolorenz

ASKER

Your solution worked.

Thanks,

Dan