Git Product home page Git Product logo

Comments (3)

jcfr avatar jcfr commented on May 28, 2024

See also http://public.kitware.com/gitweb?p=MIDAS/Midas3.git;a=blob;f=core/layouts/layout.phtml;h=3bff258187f673c1b4ea9c8a30483229169b8a0a;hb=HEAD#l375

from slicerappstore.

zachmullen avatar zachmullen commented on May 28, 2024

To answer your question, yes, this is a commonly used way to pass such data. The javascript is written separately from the views, and we do not populate any of our javascript from the controllers. The controllers can only pass data to the views, therefore we have to go through the view to pass data to our javascript. This is a good thing: it makes our javascript code static so that browsers can cache it; only the view code has to be dynamic. An alternative might be to never pass json through the view, but to force every view (via js) to re-request the server to get its json, but this would that would be expensive, redundant, and break atomicity. Either way, we have to get a serialized json object and then parse it into a hierarchy, so we might as well do it via the same request. Storing it inside a DOM element is just a mechanism for naming the data essentially.

The data() function of jQuery is used to store arbitrary data on DOM nodes. We use it in many places, but it is unrelated to the problem of passing data from the view into our javascript context, since you can only use it if you already have the data in your javascript context. If you have that, then the problem is already solved :)

You're right, we should probably namespace both the div and the globally scoped variable that we use to store our passed json. ("#midasJsonContent" and "var midas.json").

from slicerappstore.

zachmullen avatar zachmullen commented on May 28, 2024

Note that renaming json to midas.json would be another significant javascript refactor, as we reference it in many many scripts in core as well as modules.

from slicerappstore.

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.