Code Monkey home page Code Monkey logo

Comments (3)

jbwyme avatar jbwyme commented on August 10, 2024

Also seeing this issue, anyone have any suggestions?

from requirejs-rails.

jwhitley avatar jwhitley commented on August 10, 2024

I think this may be a problem related to changes in RequireJS 2.x. See Upgrading to RequireJS 2.0, especially:

So RequireJS 2.0 will not execute the module's factory function (the function passed to define()), until there has been a require([]) call that has asked for it, or something that depends on it. The use of data-main on the require.js script tag counts as a require([]) call, so most best-practices use of require.js should not notice a difference.

IIRC, you can try changing the top-level page define calls to require calls and see if that works. Apologies for the delayed response; I've been very heads-down on work issues followed by some travel with virtually no 'net access. If that doesn't work, give a holler on the requirejs group to see if anyone there has suggestions for you.

from requirejs-rails.

heartcode avatar heartcode commented on August 10, 2024

Hi @jwhitley,

Thanks for your reply. We found the solution in the mean time, but we have been a bit busy here, so haven't had the chance to post it.

We've also found that using require and creating an instance of the module solves the problem.

After the original require script tag we added the following:

<script>
  require(['page1'], function(FirstPage){
    var page = new FirstPage();
  })
</script>

Now it works like a charm :)

Cheers!

from requirejs-rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.