How to call a function (not AJAX) after executing another function (not AJAX) in Dojo?

This is not an AJAX request / response callback question ...

I am building a grid using Dojo 1.5. I am trying to dojo.connectexpand / contract buttons using a function. My problem is that the method grid.startup()seems to take some time after the call before the actual DOM nodes are created, so when I call dojo.query, none of the DOM nodes that I want to connect events and handlers to is present.

I have a grid created inside a method init()that is being called dojo.addOnLoad(). I have a method connectExpandos()connected to init()via dojo.connect("init", connectExpandos);. This works fine, but I need setTimeout()in a while loop to wait for grid.startup () to complete ...

Does anyone know of a better way to do this? Perhaps a callback grid.startup()I can hook up?

+3
source share
4 answers

Another suggestion ... looks like a โ€œrunโ€ function, which is implemented in the DataGrid superclass, _Grid (http://svn.dojotoolkit.org/src/ dojox / trunk / grid / Grid.js), calls a function called render, which , I believe, is what actually displays the contents of the Grid. Subsequently, it looks like visualization of calls using the "postrender" method after it has finished rendering. Perhaps you can associate your method with the "postrender" method instead of "startup".

dojo.connect(grid, "postrender", function(){connectExpandos()})
+3

, , , _onFetchComplete

dojo.connect(grid,'_onFetchComplete',function(event){
    alert("hello data is loaded")
});
+1

I think you can just connect the event to the grid trigger method

dojo.connect(grid, "startup", function(){connectExpandos()})
0
source

You can try to create a widget programmatically (if you havenโ€™t already), and then just call your method after calling startup () (It seems strange to call startup () manually, but the example that it shows in the original comments shows a call to grid.startup () manually).

<script type="text/javascript">
   var grid = new dojox.grid.EnhancedGrid({plugins : {nestedSorting: true, dnd: true, indirectSelection: true, 
   menus:{headerMenu:"headerMenuId", rowMenu:"rowMenuId",  cellMenu:"cellMenuId",selectedRegionMenu:"selectedRegionMenuId"}},
   ... }, dojo.byId('gridDiv'));
   grid.startup();
   connectExpandos();
</script>
0
source

Source: https://habr.com/ru/post/1765169/


All Articles