Comments (7)
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.
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.
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.
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.
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.
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.
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)
- Need escape content in ef/content or make other function that do correct html escaping.
- transform object DocumentFragment to string HOT 5
- event handler functions within hiccup-html HOT 2
- replace-vars broken in clojurescript 1.7.145 HOT 6
- Great project
- Extractor extract node HOT 1
- Clone-for and lists HOT 15
- Hiccup input control - checked and disabled not working HOT 2
- Requiring enfocus.macros under Clojure 1.10 and above triggers an error
- compiling fails at target/cljsbuild-compiler-0/enfocus/core.cljs HOT 4
- get-prop doesn't work on data attributes HOT 1
- listen-live looses event information HOT 6
- Multiple Extractions HOT 5
- Add optional callback for when view-binding function completed HOT 6
- debug should be set to false by default HOT 4
- (read-form) on IE8 results in [object]is not ISeqable HOT 7
- How can I use holder.js in html snippet? HOT 4
- Difference in ef/content behaviour HOT 2
- clone-for issue "TypeError: enfocus.core.last_element_child is undefined" HOT 1
- Function based inline snippets HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from enfocus.