Javascript for PJax option scrollTo

I would like to make the page scroll to the beginning of ListView section (starting with let’s say <div id=“v1” … >) after the PJax request succeds. To achive this, I need to pass a javascript snippet to the $scrollTo attribute. However, it renders to a string instead of a javascript code.

How to achive this?

My code:


Pjax::begin(['scrollTo' => '$("#v1").offset().top', 'linkSelector'=>'.pagination a']);

I get:


jQuery(document).pjax(".pagination a", {"push":false,"replace":false,"scrollTo":"$(\u0022#v1\u0022).offset().top","container":"#p0"});

but i need:


jQuery(document).pjax(".pagination a", {"push":false,"replace":false,"scrollTo":$('v1').offset().top,"container":"#p0"});

http://www.yiiframework.com/doc-2.0/yii-web-jsexpression.html

Thanks a lot, I could the code snippet instead of a string… but it seems that ‘scrollTo’ accept only integer or false; I couldn’t make it work.

Isn’t “$(”#v1").offset().top" an integer?