Slawomir
Slawomir

Reputation: 3343

pagerjs access url parameters in withOnShow

I'd like to (asynchronously) fetch model-data each time a page is shown. The path may have additional parameters telling the withOnShow-handler what fields to fetch, for example:

..#!/navigation/href_with_params/users/123?fields=a,b,c,d

How would you access the "fields"-param inside the withOnShow handler?

Cool.loadUser = function(callback, page) {
$.get('users/' + page.currentId + "?fields=" + <fields>, function(data) {
  callback(ko.mapping.fromJSON(data));
  });
};

Upvotes: 3

Views: 383

Answers (1)

finnsson
finnsson

Reputation: 4067

you could do something like

var fields = page.ctx.field();

inside your withOnShow. Hope this helps.

Upvotes: 4

Related Questions