jquery - pagedlist in partial view not working correctly- MVC4 -


I have implemented paging in my partial view.

This is my paging -

  & lt; Div class = "endorsement-perfect" & gt; @ Html.PagedListPager (model, page => Url.Action ("_AllVendors", new {page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter, @Class = "endorsement"}))  < / 

Now I wanted to load results according to the pages under this partial view.

So I did not use this script to navigate to the partial view page.

  & lt; script type = "text / javascript" & gt; $ (Function () {$ ('endorsement-right A'). (Function () {var page = $ (this) .text (); if (this.href == "") {return;} Else {$ .ajax ({url: this.href + '& amp; page =' + Page, type: 'GET', cache: incorrect, success: function (result) {$ ('# allenders-partial'). Html result);}});} return false;});}); & Lt; / Script & gt;   

I am loading results in a single device with ID- allenders-partial .

Problem -

I'm having trouble when any page is clicked again, then it should be div ubiquitous- Partial does not load in , instead it goes into its partial view.

How can I work it properly?

first item - e.preventdefault ():

As you have your own There are several return points in the code, e.preventDefault (also check for anchor's default click behavior (even blank href for which the page will be reloaded).

This is your call if you want to reload a page when you click on an empty href, but do not add eprevertdefault () like this:

 < code> & lt; Script type = "text / javascript" & gt; $ (Function () {$ ('endorsement-correct A'). (Function (e) {e.preventDefault ();   

If you decide to use it , Then you use the second item - event delegation:

You are reloading your paging anchor again via partial page, so return to false false . < / P>

is not required for you to use the representative version of to :

& lt; script type = "text / javascript" & gt; $ (function () {$ (document) .on ('click', '.pagination-right a', function (e) {e .preventDefault (); var page = $ (this) .text (); if (this.href == "") {Return;} else {$ .ajax ({url: this.href = '& amp; page = '+ Page, Type:' GET ', Cache: Incorrect, Success: Work (Results) {$ (' #AllWonder HTML (Result);}}}}} Returned Liar; // If you want E.Private Default () ;});});

It works by catching click at high irreversible levels of DOM (i.e. Does then the jQuery selector / file Apply R and click that was what clicked.

Actually, if you use Ajax to change the controls on the page, then you are changing / removing any event handlers that they were associated with (e.g., .click ( ...) ).

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -