Few points that you need to cover:
- all the ToClientTemplate extensions when you position widget inside a client template.
escape the sharp symbols if you have used any inside your widget declaration:
function(e) { e.data = { id: $("\#Id").val() }; }