Giter Club home page Giter Club logo

Comments (7)

ckirkendall avatar ckirkendall commented on July 28, 2024

I think you are dealing with the incoming ajax content not loading before you make the call not the local dom not existing. Snippets and/or templates are loaded via AJAX and it is important to make sure the content has been loaded before calling the template or snippit function. Enfocus provides a convient function that works like an onload callback but for AJAX driven snippets and templates.

(em/wait-for-load (render-page)) 

from enfocus.

ckirkendall avatar ckirkendall commented on July 28, 2024

On the attaching to the live dom, unfortunately, this is unavoidable because DocumentFragment has very few features for selection and manipulation. Most of the CSS3 selectors would not work on a DocumentFragment, so we temporarily add it to the live dom so it can be transformed and then pull it out into a DocumentFragmnt and pass it back.

from enfocus.

EwenG avatar EwenG commented on July 28, 2024

I forgot to mention I am using :compiled templates so I think there is no ajax involved. I understand the DocumentFragment must be added to the DOM in order to be manipulated.

When creating a template with the :compiled argument, it seems that DocumentFragment are added to the body property of the document element ( "(.-body (dom/getDocument))" ). This is an issue when trying to create templates before the DOM is loaded because the body property is not defined at that time. I have been wondering what would be your opinion about changing "(.-body (dom/getDocument))" to something like "(.-documentElement (dom/getDocument))", since the documentElement property seems to be defined even before the DOM is loaded.

from enfocus.

ckirkendall avatar ckirkendall commented on July 28, 2024

Can you post some code to repo or gist so i can try to reproduce the
issue. Also can i have your OS and Browser versions. I can try it out
your idea out this evening if you can get me the code.

CK
On Jan 27, 2013 1:47 PM, "Ewen0" [email protected] wrote:

I forgot to mention I am using :compiled templates so I think there is no
ajax involved. I understand the DocumentFragment must be added to the DOM
in order to be manipulated.

When creating a template with the :compiled argument, it seems that
DocumentFragment are added to the body property of the document element (
"(.-body (dom/getDocument))" ). This is an issue when trying to create
templates before the DOM is loaded because the body property is not defined
at that time. I have been wondering what would be your opinion about
changing "(.-body (dom/getDocument))" to something like "(.-documentElement
(dom/getDocument))", since the documentElement property seems to be defined
even before the DOM is loaded.


Reply to this email directly or view it on GitHubhttps://github.com//issues/41#issuecomment-12758963.

from enfocus.

ckirkendall avatar ckirkendall commented on July 28, 2024

Unfortunately, I am not able to append to the Document directly without causing errors. If you try to append directly to the document you get the following error: HIERARCHY_REQUEST_ERR: DOM Exception 3. It would be great if you could put together a repo with your code in it so I can experiment with possible solutions.

from enfocus.

EwenG avatar EwenG commented on July 28, 2024

I uploaded my code to a repo here https://github.com/Ewen0/test-enfocus.git
It can be run with: lein ring server
It simply creates a template before the dom is loaded. I could run it on firefox 18.0.1, chromium 24 and opera 12.

It can be compared to https://github.com/Ewen0/test-enfocus-body.git which produces an error.
The only difference is line 138 in core.cljs.

from enfocus.

ckirkendall avatar ckirkendall commented on July 28, 2024

ok, that makes perfect sense now. Sorry brain not working on the last attempt. I did some preliminary testing and all looks good. I want to do more testing but I would love a pull request for the change.

from enfocus.

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.