javascript - MVC, how get model property from response viewModel -




iam implementing "show more post" in blogs list following this example

but want make little change , switch viewdata viewmodel

this relevant code:

private void addmoreurltoviewdata(int entrycount) {     viewdata["showmore "] = url.action("index", "messaggi", new { entrycount = entrycount + defaultentrycount }); } 

that switch to

viewmodel.showmore = url.action("index", "messaggi", new { entrycount = entrycount + defaultentrycount }); 

the index action of example:

public actionresult index(int? entrycount) { if (!entrycount.hasvalue)     entrycount = defaultentrycount;  int totalitems;  if(request.isajaxrequest()) {     int page = entrycount.value / defaultentrycount;      //retrieve page specified page variable page size o defaultentrycount     ienumerable<entry> pagedentries = getlatestentries(page, defaultentrycount, out totalitems);      if(entrycount < totalitems)         addmoreurltoviewdata(entrycount.value);      return view("entryteaserlist", pagedentries); }  //retrieve first page page size of entrycount ienumerable<entry> entries = getlatestentries(1, entrycount.value, out totalitems);  if (entrycount < totalitems)     addmoreurltoviewdata(entrycount.value);  return view(entries); } 

here add lot of code load post db, code think relevant swtich return view("entryteaserlist", pagedentries); return view(myviewmodel); after setting blogslist , showmore property

but problem in javascript command:

$(function() {     addmorelinkbehaviour(); });  function addmorelinkbehaviour() { $('#entryteaserlist #morelink').live("click", function() {     $(this).html("<img src='/images/ajax-loader.gif' />");     $.get($(this).attr("href"), function(response) {         $('#entryteaserlist ol').append($("ol", response).html());         $('#entryteaserlist #showmore').replacewith($("#showmore", response));     });     return false; }); } 

where

$('#entryteaserlist #showmore').replacewith($("#showmore", response)); 

take viewdata property , use replace link

how can read viewmodel proeprty instead?





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -