JavaScript document.Body ComponentQuery

I am using an awesome html2canvas function but I have a noob question. How do I change the field it is capturing from document.body to a specific panel? In short i need to change document.body to the panel I want to capture, I just don't know the code to get the panel I want.

I have tried Ext.ComponentQuery.query('#testPanel') without any success.

testButtonClicked: function (btn) {

    html2canvas(document.body, {
        onrendered: function (canvas) {
            new Ext.Window({
                title: 'Screenshot',
                //width: 500,
                height: 800,
                resizable: true,
                autoScroll: true,
                preventBodyReset: true,
                html: '<img src="' + canvas.toDataURL("image/png") + '" height="800"/>'
            }).show();
        }
    });
Answer:1

You want getEl().dom. Here's a standalone example (tested with Ext 4.2.x):

Ext.onReady(function () {

    Ext.define('Panel', {
        extend: 'Ext.panel.Panel',

        frame: true,
        title: 'Test Panel',
        width: 300,
        height: 300,

        onClick: function () {
            html2canvas(this.getEl().dom, {
                onrendered: function (canvas) {
                    new Ext.Window({
                        title: 'Screenshot',
                        width: 300,
                        height: 300,
                        html: '<img src="' + canvas.toDataURL("image/png") + '"/>'
                    }).show();
                }
            });
        },


        initComponent: function () {
            var config = {
                items: [
                    {
                        xtype: 'datepicker'
                    },
                    {
                        xtype: 'button',
                        text: 'CAPTURE THIS PANEL',
                        handler: this.onClick,
                        scope: this
                    }
                ]
            };

            Ext.apply(this, Ext.apply(this.initialConfig, config));
            this.callParent(arguments);
        }
    });


    var panel = Ext.create('Panel', {
        renderTo: Ext.getBody()
    });
});
Answer:2

I cant find why my code isn't working. When I click on the generated element the alert is not firing. Here is a fiddle : http://jsfiddle.net/pZAdP/ And the code <button id="addMenuItem">Add ...

I cant find why my code isn't working. When I click on the generated element the alert is not firing. Here is a fiddle : http://jsfiddle.net/pZAdP/ And the code <button id="addMenuItem">Add ...

  1. jquery click event not firing
  2. jquery click event listener
  3. jquery click event target
  4. jquery click event firing twice
  5. jquery click event not working on mobile
  6. jquery click event get element
  7. jquery click event on class
  8. jquery click event function
  9. jquery click event stop propagation
  10. jquery click event parameters
  11. jquery click event only works once
  12. jquery click event get element id
  13. jquery click event for dynamic elements
  14. jquery click event on anchor tag
  15. jquery click event pass parameter
  16. jquery click event on pseudo element
  17. jquery click event on element
  18. jquery click event on disabled input
  19. jquery click event order
  20. jquery click event get href

I have a table and in one td I have an another table. What I am trying to do is select only the last tr from the first table (which is represented in the example below). My table HTML: <table&...

I have a table and in one td I have an another table. What I am trying to do is select only the last tr from the first table (which is represented in the example below). My table HTML: <table&...

  1. jquery select last element
  2. jquery select last child
  3. jquery select last option
  4. jquery select last row of table
  5. jquery select last of type
  6. jquery select last li in ul
  7. jquery select last element with class
  8. jquery select last option in dropdown
  9. jquery select last child of parent
  10. jquery select last element in array
  11. jquery select last two elements
  12. jquery select last child with class
  13. jquery select last div
  14. jquery select last of class
  15. jquery select last character of string
  16. jquery select last item
  17. jquery select last tr
  18. jquery select last td in tr

I have 2 jstrees and now I am trying to implement a drag and drop option between them, but I can't seem to manage to obtain the id's of the element i am dragging or the new parent's id (after drag and ...

I have 2 jstrees and now I am trying to implement a drag and drop option between them, but I can't seem to manage to obtain the id's of the element i am dragging or the new parent's id (after drag and ...

Here is my code so far: dojoConfig = {parseOnLoad: true}; resetStopwatch(); require(["dojo/query", "dijit/form/ToggleButton", "dijit/form/Button", "dojo/dom", "dojo/dom-attr", "dojo/...

Here is my code so far: dojoConfig = {parseOnLoad: true}; resetStopwatch(); require(["dojo/query", "dijit/form/ToggleButton", "dijit/form/Button", "dojo/dom", "dojo/dom-attr", "dojo/...

  1. change button text javascript
  2. change button text on click
  3. change button text jquery
  4. change button text color
  5. change button text swift
  6. change button text unity
  7. change button text css
  8. change button text color swift
  9. change button text color css
  10. change button text tkinter
  11. change button text excel
  12. change button text onclick react
  13. change button text android studio
  14. change button text on hover
  15. change button text vba
  16. change button text size
  17. change button text color bootstrap
  18. change button text java
  19. change button text color react native
  20. change button text squarespace