views:

302

answers:

1

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.

+2  A: 

Surely if you are using AJAX to refresh the table, you have a function that gets called to request your data. If there is an onSuccess function, you could just call the striping in there.

Paddy
Great idea .... function reDraw gets called up, but for some reason JQuery is not dressing up the boy :( .... following is my code:$("table.gridtable tbody tr:even td").addClass("even");$("table.gridtable tbody tr:odd td").addClass("odd");
effkay
Have you stepped in and made sure jQuery can see your updated table? How are you updating the DOM after the AJAX response?
Paddy
I am using over-write method; i.e., asp .net mvc ajax over-writes with what it gets from ajax call. I will check it tomorrow;thanks for the great help.
effkay
My bad .... I was using onComplete...
effkay