0

Using ajax to render a partial view, then on success need to show new data (which works) but the css is not being applied, ideas?

$.ajax({
                     url: baseUrl,
                     type: 'GET',
                     data: { date: date },
                     success: function (response) {
                         $('#schedule').html(response);
                     },
                     complete:function() {  $('#listId').listview('refresh');
                     },

                 });

View

 <ul data-role="listview" data-divider-theme="b" data-inset="true" id="listId">
                    <li data-role="list-divider" role="heading">
                        @Model.AppointmentDate
                    </li>
                    @foreach (var item in Model.Appointments)
                    {
                        <li data-theme="c">
                            <a href="/Schedule/MobileAppointmentEdit/@item.Id" data-transition="slide">
                                @item.StartTime @item.Name
                            </a>
                        </li>
                    }

                </ul>

1 Answer 1

1

You should refresh ul in ajax success but not ajax complete. It is because jquery mobile applys css when the page init, for the data that retrieve dynamically. You have to trigger an event to refresh the UI.

jQuery Mobile listview ref: http://jquerymobile.com/demos//1.2.0/docs/lists/lists-methods.html

success: function (response) {
   $('#schedule').html(response);
   $("#schedule ul").listview();
},
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.