Comments (11)
I think the two problems are unrelated. I know of the domina issue and I am now a committer on the project and trying to work on a new release. The second issue is due to invalid syntax of the "at", "defsnippet" or "deftemplate" forms. Can you post the event code you were trying to use? I think I can help with that issue pretty quick.
CK
from enfocus.
Thanks for looking into it,
Oddly enough this was working but now I am realizing that this is a very silly way of using this:
(em/defsnippet portfolio-item "templates/data.html" selector [])
It pulls in the data but all of it at once. I guess I expected it to do the selector query when I call portfolio-item
.
What I was trying to accomplish is a way to have an arbitrary amount of 'data' items in the data.html file and pull them as needed based on user selection.
(defn toggle-projects [project]
(ef/at "#container"
(ef/content (portfolio-item project []))))
What would be the correct method for organizing defsnippet here?
[As an aside] I did end up getting this all running via async channels, as an update to my question on the mailing list from a few weeks ago. Still writing pretty horrid code though. :)
from enfocus.
@BorisKourt I am a little confused as to what you are trying to do. Snippet are realized on load of the page and/or on compile if the :compiled key is added. defsnippet creates a function that takes the arguments defined in the last set of brackets in your example. So in your example portfolio-item would not take any arguments. Generally you would qualify each item in data.html with a separate snippet like so:
(defsnippet data-item1 :compiled "templates/data.html" "#item1" [])
(defsnippet data-item2 :compiled "templates/data.html" "#item2" [])
On another note. I put together an example application using enfocus and core.async called chatter-box. You can find it here if you want some ideas. https://github.com/ckirkendall/chatter-box
CK
from enfocus.
I also did a presentation on core.async and enfocus that featured chatter-box that might help you. http://www.youtube.com/watch?v=jj6eQieGWqo
from enfocus.
Watched your talk yesterday, was very insightful. Wish I was at the stage where I was comfortable with clojure in the backend. Currently I am just practicing ClojureScript for just user interfaces. :)
As for the issue, I guess I thought I could pass it the selector as a parameter in order to not have multiple snippet calls hardcoded.
What I am trying to do is have a dynamic menu with each item having a data attribute that has the name of the specific data section.
Each section of data.html is wrapped in a div with that name as its class.
When a user clicks on the menu item, it calls the snippet function and prints out only the data within that selector.
Is there a way to do that with enfocus? Otherwise I will add individual snippet functions for each of the items and hardcode the menu. Or show and hide with html and enfocus selectors.
Thanks again for the feedback and the talk.
from enfocus.
Can you post data.html to gist. I think I can give you a solution.
CK
On Mon, Sep 16, 2013 at 8:47 PM, Boris Kourtoukov
[email protected]:
Watched your talk yesterday, was very insightful. Wish I was at the stage
where I was comfortable with clojure in the backend. Currently I am just
practicing ClojureScript for just user interfaces. :)As for the issue, I guess I thought I could pass it the selector as a
parameter in order to not have multiple snippet calls hardcoded.What I am trying to do is have a dynamic menu with each item having a data
attribute that has the name of the specific data section.Each section of data.html is wrapped in a div with that name as its class.
When a user clicks on the menu item, it calls the snippet function and
prints out only the data within that selector.Is there a way to do that with enfocus? Otherwise I will add individual
snippet functions for each of the items and hardcode the menu. Or show and
hide with html and enfocus selectors.Thanks again for the feedback and the talk.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/60#issuecomment-24556691
.
from enfocus.
It's a very small test set:
https://gist.github.com/BorisKourt/6588769
from enfocus.
here is an idea:
(deftemplate portfolio-item "..." [class]
(str "div:not(." class ")") (remove-node))
from enfocus.
Sorry for such a long delay, I was having way too many issues with core.async recently due to them being behind clojurescript that I had to move on and finish the project using entirely different tech in just a couple of days.
I came back to this and am currently just using enfocus without the rest. Here is how it looks like:
Base File:
(ns ui.core
(:require [enfocus.core :as ef]
[enfocus.effects :as effects]
[enfocus.events :as ev]
[ui.templates :as t :refer [portfolio-item]])
(:require-macros [enfocus.macros :as em]))
(def log #(.log js/console %))
(defn toggle-project [project]
(log (str "div:not(" project ")")) ;; Logs the current passed project as it would appear
(ef/at "#container"
(ef/content (portfolio-item [project]))))
(em/wait-for-load (toggle-project ".item-1")) ;; Is a test replacement for a future click event.
CLJS template namespace:
(ns ui.templates
(:require [enfocus.core :as ef]
[enfocus.effects :as effects]
[enfocus.events :as ev])
(:require-macros [enfocus.macros :as em]))
(em/deftemplate portfolio-item "templates/data.html" [class]
(str "div:not(" class ")") (ef/remove-node))
When I run this I get a proper console.log of div:not(.item-1)
but the #content
is populated with nothing.
To debug I modified the template file with: (str "div:not(.item-1)") (ef/remove-node))
which is an explicit call for item-1. That worked and output the one item correctly into #content
, alas that is not the dynamic functionality I am looking for.
I am assuming that is because it happened on load of template, and after the fact it doesn't accept a dynamic call for a different item?
Thanks again for looking into this.
from enfocus.
I see the issue. You wrapped the parameter to portfolio-item in a vector before you passed it to the function. So instead of passing ".item-1" you passed [".item-1"]. The code should look like the following.
(defn toggle-project [project]
(log (str "div:not(" project ")")) ;; Logs the current passed project as it would appear
(ef/at "#container"
(ef/content (portfolio-item project))))
from enfocus.
Ah my bad, these small things get me all the time still :(
Thanks for your help, going to close this.
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.