简体   繁体   中英

MVC 4 - using PagedList with Ajax.ActionLink throws off all javascript/jQuery after initial navigation

I'm using the PagedList nuget package in a partial view in my application. My partial contains a number of buttons that open bootstrap modal windows. There's also some sections of the partial where I use a jQuery plugin that truncates multi-line text.

On initial page load, everything works - truncation, bootstrap JS features etc. When I navigate to the second page of results, and then back to the first all of these features stop working.

The links used to navigate pages are Ajax.ActionLink():

 @Ajax.ActionLink("Next >", "GetAllProperties", new { page = Model.PageNumber + 1 }, 
new AjaxOptions { UpdateTargetId = "quick-property-search-results" })

I've used $(document.body).on('click', '.view', function (e) {...}; in all my jQuery functions to bind event handlers after document.ready, but still no joy. After navigating back/forth through 'paged' pages, if I try to open a modal I'll get

Object [object Object] has no method 'modal'

I've created a collabedit which illustrates a simplified version of my layout, view and partial view with hopes that it may offer more insight to the problem.

Would really appreciate a solution to this one.

Found out what the issue was. In the partial where I am using pagination, I had an additional reference to jQuery, so, I think anything that was bound to jQuery initially, wasn't after an Ajax.ActionLink() made a GET request for any additional 'paged' pages, hence I was getting Object [object Object] has no method 'X'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM