Giter Club home page Giter Club logo

Comments (11)

ckirkendall avatar ckirkendall commented on July 28, 2024

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.

BorisKourt avatar BorisKourt commented on July 28, 2024

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.

ckirkendall avatar ckirkendall commented on July 28, 2024

@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.

ckirkendall avatar ckirkendall commented on July 28, 2024

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.

BorisKourt avatar BorisKourt commented on July 28, 2024

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.

ckirkendall avatar ckirkendall commented on July 28, 2024

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.

BorisKourt avatar BorisKourt commented on July 28, 2024

It's a very small test set:

https://gist.github.com/BorisKourt/6588769

from enfocus.

ckirkendall avatar ckirkendall commented on July 28, 2024

here is an idea:

(deftemplate portfolio-item "..." [class]
  (str "div:not(." class ")") (remove-node))

from enfocus.

BorisKourt avatar BorisKourt commented on July 28, 2024

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.

ckirkendall avatar ckirkendall commented on July 28, 2024

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.

BorisKourt avatar BorisKourt commented on July 28, 2024

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)

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.