I'm not quite sure what you are trying to do, but instead of embedding javascript in return, there are client-side scripts that you can connect to. I would give your DOM elements a unique class and then set ClientSideEvents.EndCallBack.
settings.ClientSideEvents.EndCallback = "function (s,e) { if (e.command != 'FUNCTION') { YourCustomMethod(s, e) }; }";
some simple jquery or direct javascript will allow you to get a list of DOM objects matching your class name as a selector, and you can include any additional data needed for processing in the data properties.
In your example, a partial view looks something like this:
<p class="actonme" data-msg="hello from PartialView">text</p>
and your method will look something like this:
function YourCustomMethod(s, e) { var objs = document.getElementsByClassName('actonme'); var count = objs.length; for (var iIndex = 0; iIndex < count; iIndex++) { console.log(objs[iIndex].getAttribute("data-msg")); } }
source share