Fork me on GitHub
#clojurescript
<
2020-02-15
>
pinkfrog14:02:29

$(document).ready(function() {

  // Check for click events on the navbar burger icon
  $(".navbar-burger").click(function() {

      // Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
      $(".navbar-burger").toggleClass("is-active");
      $(".navbar-menu").toggleClass("is-active");

  });
});

pinkfrog14:02:12

So I have the above code in jquery. Is there any cljs equivalent library or should I stick with jquery?

dazld14:02:56

you can do all of that with the native dom apis!

dazld14:02:19

for that code in particular, if there’s nothing else, I guess cljs doesn’t really help you out

dazld14:02:38

what are you looking for, in particular?

pinkfrog15:02:28

new to cljs dev. I am thinking what’s the most common way to achieve that specific problem in the cljs setting.

pinkfrog15:02:02

So I found, 1. goog library. 2. cljs js interop. 3. reagent/reframe stuff. Either is fine. I might go with 2 for this problem.

dazld15:02:54

that sounds like a good way to start

dazld15:02:12

you definitely don’t need reagent / react for any of that

dazld15:02:11

but, if you’d like to just try the syntax first, doing some simple dom stuff sounds like a good way to go

pinkfrog15:02:01

<button onclick=“myFunction()“>Click me</button>

pinkfrog15:02:28

suppose I have a function fun defined in (ns myapp.f)

pinkfrog15:02:46

how can i call myapp.f.fun instead of the myFunction() ?

p-himik15:02:31

Do you control the button?

p-himik15:02:57

If so, just change its definition. If not, you can still change its on-click event handler, I think.

dominicm16:02:14

I think you need export metadata on the function

dominicm16:02:25

Then it's just my.ns.fn()

john-shaffer17:02:50

I want to publish a library with both Clojure and ClojureScript files. I'd like to include the ClojureScript as dev dependencies while using the Clojure files as normal dependencies. Is there a cleaner way to do this other than creating two libraries and having users set up their deps.edn/project.clj appropriately, or is that the best practice?

lilactown19:02:01

ClojureScript files are only included in your application if you require them in a namespace. So it will be up to users to figure out how to include them only at dev time either way