ASP .NET MVC; return HTML along with JavaScript

Posted by effkay on Stack Overflow See other posts from Stack Overflow or by effkay
Published on 2009-11-30T11:55:14Z Indexed on 2010/04/03 4:43 UTC
Read the original article Hit count: 457

Filed under:
|
|
|

I have a partial view which renders a table.

On page load, I am using JQuery to perform Zebra Stripping on it.

Whenever ajax refreshes the table, DOM elements are updated, but since JQuery code to do the Zebra Stripping is not executed; table looks ugly.

I have tried adding Javascript in my partial view

        if( Request.IsAjaxRequest() )
            return PartialView( "AdministrationGrid", Users );

but javascript is not executed.

I guess the only way to execute the Javascript as reply is to do:

return JavaScript( "alert( '' )" );

Anyone with an idea how can I achieve this?

I thought about JQuery Live, but it is used to bind itself to events.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about asp.net-mvc