Brunch adventure

Just finished the phoenix tutorial and now trying some things out. First: add a selectionlist to the header of the ‘welcome’ screen. I downloaded the twitter dropdown.js + jquery and put them in priv/static/js, edited brunch-config.js to load jquery first and put something like


  • Page 1



  • in web/templates/layout/app.html.eex . It did not work as expected after I started phoenix.server, so I wanted to remove the js files from priv/static/js. To my surprise they had been removed already, two other js files were generated in their place. Ok, then remove those. I removed the changes from brunch-config.js and web/templates/layout/app.html.eex. Restarted phoenix.server. Chrome caching is disabled. But still I get an error about dropdown.js missing jquery when navigating to the welcome screen, in chrome. In the chrome console I can still see dropdown.js + jquery. Are there more places where I have to remove / change things?
    1 Like

    Btw fun to see my html translated (in the previous message).

          //<li class="dropdown">
             //<a class="dropdown-toggle" data-toggle="dropdown" href="#">Page 1
             //<span class="caret"></span></a>
            //<ul class="dropdown-menu">
               //<li><a href="#">Page 1-1</a></li>
               //<li><a href="#">Page 1-2</a></li>
              //<li><a href="#">Page 1-3</a></li>
             //</ul>
          //</li>
    1 Like

    As @chrismccord pointed out to me a few days ago: The proper place to add JS files to is web/static/js for things you want Brunch to compile and add to your app.js, and web/static/assets/js for things you want to copy over 1:1 without changes. This second place is where you can add libraries like dropdown.js. Both of these folders will end up in the root folder priv/js.

    To add static files to your application, add a line like <script src="<%= static_path(@conn, "/js/filename.js") %>"></script> to your template file(s).

    3 Likes

    Thanks, I will try that. But in the meanwhile: how do I get rid of the mess that I obviously have now? I thought I cleared everything.

    1 Like