How do I use a value from a details view on a page in javascript

I would like to use a value from a details view on a page in javascript. I have used the Knack.models.view_303.data.models.map(function (r) { return r.toJSON();}) operator for tables many times before, but this does not seem to work for a details view. It there a different method for a details view?

Even if it’s a detail view, it should still follow Knack’s view render JS module. Something as simple as the following code should help achieve it:

$(document).on('knack-view-render.view_xx', function (event, view, data) {
    var value = data.field_yy;
    console.log(value);
});

HI Arjun,
That is very helpful thank you. Problem solved.

1 Like