tags:

views:

107

answers:

1

Hi,

I'm working with MVC's views

I have a main view which contains a partial view. My partial view is rendered with the actions that are fired from the elements that it contains. I also have a jquery of tooltips from "Qtip". Everything works fine.

My problem is that everytime I render the partial view, the complete functionality of the jquery is lost and my tooltips don't work.

Thanks

A: 

This behaviour is expected because the new elements created when rendering the partial view do not have any javascript/jQuery properties/functions/etc. You will have to re-add these jQuery tooltips after the partial view is rendered.

You can do this by adding an "OnSuccess" option to the MVCAjax form, e.g.,

<% using (Ajax.BeginForm("Index", new AjaxOptions
    {
       LoadingElementId = "loading",
       OnSuccess = "functionCall",
       UpdateTargetId = "list-current"
    }))
    { %>

You then need the javascript

function functionCall(result) {
    // re-attach jquery to objects
    // and/or do anything with return value "result"
}
Andrew Mcveigh
Thanks Andrew, your solution helped me to solve my problem.
cer