Вопрос

I'm trying to call a function with arguments from Telerik grid ClientTemplate, like this:

.ClientTemplate("<a href=\"javascript:OnModifyDescription('<#= Value1 #>');\" title='Modify'>...</a>")

When the Value argument contains a single quote then on clicking the link results in the error: "Uncaught SyntaxError: Unexpected identifier".

What is the correct way to bind a function in a ClientTemplate?

Thanks in advance.

Это было полезно?

Решение

Make your client template as this :

.ClientTemplate("<a class='MyClass' myAttrib='<#= Value1 #>') title='Modify'>...</a>")

Then write the following scripts at top of your page:

<script>
$('a.MyClass').live('click',function(){
   var myVal = $(this).attr('myAttrib');
   OnModifyDescription(myVal);
});
</script>

Check this for jquery live function : http://api.jquery.com/live/

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top