开发者

MVC Partial Views - Qtip

开发者 https://www.devze.com 2022-12-14 11:59 出处:网络
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

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.

T开发者_如何学运维hanks


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"
}
0

精彩评论

暂无评论...
验证码 换一张
取 消