jquery - Javascript function not found on certain environments having slow connectivity -


following exact scenario in mvc application:

there 1 page (cshtml) having grid. within each row of grid, have button. clicking on button suppose open popup (which partial view). partial view contains kendo grid, in order apply common behavior kendo grids in our application, have created 1 javascript library (customgrid.js) bundled inside "~/javascript/customgrid" bundle.

bundle rendering code placed @ top of partial view:

@scripts.render("~/javascript/customgrid") 

within partial view, creating kendo grid columns , all. following javascript written @ bottom of page in order apply common behavior grid.

<script type="text/javascript" language="javascript">     $(document).ready(function () {         //bind plugin          var objgrid = $('#historytrackgriddiv').setupgrid({             loaddefaultview: false,             allowpaging: true,             allowviews: false,             allowcolumnhideshow: false,             allowsaveas: false,             allowrefresh: false,             pagesize: [10, 25, 50, 100, 200]         });     }); </script> 

this works fine on development environment, few testing environments hosted locally. while accessing site specific testing environments gives following error:

uncaught typeerror: $(...).setupgrid not function @ htmldocument.eval (eval @ (jquerypackage?v=23.0-b68:1),

this function, , bundle used @ many other places in application, , works fine there. however, issue occurring in 1 particular page, , while hosted on specific environments.

we aware environments slow, , possible bundle may taking more time load , document.ready() getting called before bundle getting loaded.

we tried window.onload, having load() event , cannot put code in event. unable render bundle in parent page, conflicts other javascript files being used in page.

any idea of how overcome issue?

as suggested stephen, have moved scripts partial view parent view, , after see java scripts getting loaded on environments before trying execute them irrespective of connectivity speed.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -