0

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
  • The subject of the question has changed, reading your comment on Paddy's answer. Either update your question or make a new one please. Commented Nov 30, 2009 at 12:19
  • I have commented; am still debugging; will definitely post the answer as soon as I sort it out.. Commented Nov 30, 2009 at 15:25

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

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");
Have you stepped in and made sure jQuery can see your updated table? How are you updating the DOM after the AJAX response?
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.