Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly defer do?

I placed scrollIntoView() to make my grid scroll visible. When I add new grid in gridContainer so I using this method. This is working I can check from debugger. my scrollIntoView()

grid.body.dom.scrollIntoView();

But once it reached in defer function it not scrollIntoView() functioning. Can anybody please suggest how to skip this. What defer do and how to skip this. Also I am using grid.focus() and again same thing is happening. Grid is coming into view but after come out from debugger no showing into view.

defer: function(fn, millis, scope, args, appendArgs) {
  fn = Ext.Function.bind(fn, scope, args, appendArgs);
  if (millis > 0) {
    return setTimeout(function() {
      if (Ext.elevateFunction) {
        Ext.elevateFunction(fn);
      } else {
        fn();
      }
    }, millis);
  }
  fn();
  return 0;
},
like image 678
David Avatar asked Jan 30 '17 07:01

David


People also ask

What is the purpose of defer?

If the defer attribute is set, it specifies that the script is downloaded in parallel to parsing the page, and executed after the page has finished parsing. Note: The defer attribute is only for external scripts (should only be used if the src attribute is present).

Does defer happen before or after return?

Deferred statements are executed before the functions value is returned. In this case, the named return value i is incremented once the function completes, but before the value is returned to the calling statement in the main function.

Does defer execute after panic?

Panics happen after a deferred statement is executed. the program ends after the panic statement is run.

What is the purpose of Defer in script tag?

Scripts with the defer attribute will prevent the DOMContentLoaded event from firing until the script has loaded and finished evaluating.


1 Answers

A workaround would be not to scroll to the component, but to use the card layout for the center container and display the new grid on an other card.

var centerCt;  // reference to your center container
var centerLayout = centerContainer.getLayout();
var newGrid = Ext.create('Ext.grid.Panel', {});
centerCt.add(newGrid);
centerLayout.setActiveItem(newGrid);

I created a Sencha Fiddle.

like image 101
And-y Avatar answered Sep 18 '22 13:09

And-y