How to use uppy plugin with webpacker on rails











up vote
-1
down vote

favorite












I'm trying to use uppy with webpacker on rails, I am having trouble getting uppy to work:



//  app/javascripts/src/javascript/my_scripts.js    
const Uppy = require('@uppy/core')
const DragDrop = require('@uppy/drag-drop')
const ProgressBar = require('@uppy/progress-bar')

const uppyOne = new Uppy({debug: true, autoProceed: true})
uppyOne.use(DragDrop, { target: '.UppyDragDrop-One' })


This is the console error I'm receiving:



[Uppy] [23:29:46] Not installing DragDrop
Plugin.js:165 Uncaught Error: Invalid target option given to DragDrop. Please make sure that the element
exists on the page, or that the plugin you are targeting has been installed. Check that the <script> tag initializing Uppy
comes at the bottom of the page, before the closing </body> tag (see https://github.com/transloadit/uppy/issues/1042).
at DragDrop.mount (Plugin.js:165)
at DragDrop.install (index.js:204)
at Uppy.use (index.js:901)
at Object.<anonymous> (uppy.js:6)
at __webpack_require__ (bootstrap a698a4c3b9adcd1bf843:19)
at Object.<anonymous> (application.js:1)
at __webpack_require__ (bootstrap a698a4c3b9adcd1bf843:19)
at bootstrap a698a4c3b9adcd1bf843:62
at bootstrap a698a4c3b9adcd1bf843:62









share|improve this question




























    up vote
    -1
    down vote

    favorite












    I'm trying to use uppy with webpacker on rails, I am having trouble getting uppy to work:



    //  app/javascripts/src/javascript/my_scripts.js    
    const Uppy = require('@uppy/core')
    const DragDrop = require('@uppy/drag-drop')
    const ProgressBar = require('@uppy/progress-bar')

    const uppyOne = new Uppy({debug: true, autoProceed: true})
    uppyOne.use(DragDrop, { target: '.UppyDragDrop-One' })


    This is the console error I'm receiving:



    [Uppy] [23:29:46] Not installing DragDrop
    Plugin.js:165 Uncaught Error: Invalid target option given to DragDrop. Please make sure that the element
    exists on the page, or that the plugin you are targeting has been installed. Check that the <script> tag initializing Uppy
    comes at the bottom of the page, before the closing </body> tag (see https://github.com/transloadit/uppy/issues/1042).
    at DragDrop.mount (Plugin.js:165)
    at DragDrop.install (index.js:204)
    at Uppy.use (index.js:901)
    at Object.<anonymous> (uppy.js:6)
    at __webpack_require__ (bootstrap a698a4c3b9adcd1bf843:19)
    at Object.<anonymous> (application.js:1)
    at __webpack_require__ (bootstrap a698a4c3b9adcd1bf843:19)
    at bootstrap a698a4c3b9adcd1bf843:62
    at bootstrap a698a4c3b9adcd1bf843:62









    share|improve this question


























      up vote
      -1
      down vote

      favorite









      up vote
      -1
      down vote

      favorite











      I'm trying to use uppy with webpacker on rails, I am having trouble getting uppy to work:



      //  app/javascripts/src/javascript/my_scripts.js    
      const Uppy = require('@uppy/core')
      const DragDrop = require('@uppy/drag-drop')
      const ProgressBar = require('@uppy/progress-bar')

      const uppyOne = new Uppy({debug: true, autoProceed: true})
      uppyOne.use(DragDrop, { target: '.UppyDragDrop-One' })


      This is the console error I'm receiving:



      [Uppy] [23:29:46] Not installing DragDrop
      Plugin.js:165 Uncaught Error: Invalid target option given to DragDrop. Please make sure that the element
      exists on the page, or that the plugin you are targeting has been installed. Check that the <script> tag initializing Uppy
      comes at the bottom of the page, before the closing </body> tag (see https://github.com/transloadit/uppy/issues/1042).
      at DragDrop.mount (Plugin.js:165)
      at DragDrop.install (index.js:204)
      at Uppy.use (index.js:901)
      at Object.<anonymous> (uppy.js:6)
      at __webpack_require__ (bootstrap a698a4c3b9adcd1bf843:19)
      at Object.<anonymous> (application.js:1)
      at __webpack_require__ (bootstrap a698a4c3b9adcd1bf843:19)
      at bootstrap a698a4c3b9adcd1bf843:62
      at bootstrap a698a4c3b9adcd1bf843:62









      share|improve this question















      I'm trying to use uppy with webpacker on rails, I am having trouble getting uppy to work:



      //  app/javascripts/src/javascript/my_scripts.js    
      const Uppy = require('@uppy/core')
      const DragDrop = require('@uppy/drag-drop')
      const ProgressBar = require('@uppy/progress-bar')

      const uppyOne = new Uppy({debug: true, autoProceed: true})
      uppyOne.use(DragDrop, { target: '.UppyDragDrop-One' })


      This is the console error I'm receiving:



      [Uppy] [23:29:46] Not installing DragDrop
      Plugin.js:165 Uncaught Error: Invalid target option given to DragDrop. Please make sure that the element
      exists on the page, or that the plugin you are targeting has been installed. Check that the <script> tag initializing Uppy
      comes at the bottom of the page, before the closing </body> tag (see https://github.com/transloadit/uppy/issues/1042).
      at DragDrop.mount (Plugin.js:165)
      at DragDrop.install (index.js:204)
      at Uppy.use (index.js:901)
      at Object.<anonymous> (uppy.js:6)
      at __webpack_require__ (bootstrap a698a4c3b9adcd1bf843:19)
      at Object.<anonymous> (application.js:1)
      at __webpack_require__ (bootstrap a698a4c3b9adcd1bf843:19)
      at bootstrap a698a4c3b9adcd1bf843:62
      at bootstrap a698a4c3b9adcd1bf843:62






      ruby-on-rails webpacker






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 9 at 7:56

























      asked Nov 9 at 7:36









      echan00

      1,1161719




      1,1161719
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          I found out the problem is because in rails you usually link to all JS files up in the head of the layout file but the element with class '.UppyDragDrop' has yet to be rendered.



          To resolve, you need to separately link to the javascript via javascript_pack_tag after the element with the DragDrog element is presented.






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53221530%2fhow-to-use-uppy-plugin-with-webpacker-on-rails%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote



            accepted










            I found out the problem is because in rails you usually link to all JS files up in the head of the layout file but the element with class '.UppyDragDrop' has yet to be rendered.



            To resolve, you need to separately link to the javascript via javascript_pack_tag after the element with the DragDrog element is presented.






            share|improve this answer

























              up vote
              0
              down vote



              accepted










              I found out the problem is because in rails you usually link to all JS files up in the head of the layout file but the element with class '.UppyDragDrop' has yet to be rendered.



              To resolve, you need to separately link to the javascript via javascript_pack_tag after the element with the DragDrog element is presented.






              share|improve this answer























                up vote
                0
                down vote



                accepted







                up vote
                0
                down vote



                accepted






                I found out the problem is because in rails you usually link to all JS files up in the head of the layout file but the element with class '.UppyDragDrop' has yet to be rendered.



                To resolve, you need to separately link to the javascript via javascript_pack_tag after the element with the DragDrog element is presented.






                share|improve this answer












                I found out the problem is because in rails you usually link to all JS files up in the head of the layout file but the element with class '.UppyDragDrop' has yet to be rendered.



                To resolve, you need to separately link to the javascript via javascript_pack_tag after the element with the DragDrog element is presented.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 13 at 19:28









                echan00

                1,1161719




                1,1161719






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53221530%2fhow-to-use-uppy-plugin-with-webpacker-on-rails%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Landwehr

                    Reims

                    Schenkenzell