Select dynamic HTML Element via jQuery

前端 未结 2 1523
醉话见心
醉话见心 2021-01-21 16:32

I am building an ASP.NET MVC application and I am using the jQuery Blueimp plugin on a PartialView that is added dynamically to the page.

According to the Docs of the pl

2条回答
  •  天命终不由人
    2021-01-21 17:00

    So after a long discussion with Archer and many others, we figured the problem out.

    The input form was coming through a PartialView.cshtml in my ASP.NET MVC application. Even though I had my plugin initialization code wrapped around a jQuery's .on() function, the plugin was still attempting to initialize things on initial page load.

    I'm not sure why that is, my guess is that the plugin was designed that way!

    So what I did was, I moved all script files related to the plugin from MVC's _Layout.cshtml and put them inside my _PartialView.cshtml.

    This forced the plugin scripts to run as soon as the partial appeared on the page, and the plugin then worked fine.

    NOTE: You still need to ensure that the ordering of the script files is correct.

    • jQuery
    • Widget UI
    • iFrame Transport
    • FileUpload

    I hope this helps.

提交回复
热议问题