KRL: using the defaction parameter in the emitting block

I tried using the parameter in the emit block as part of a user-defined action, for example:

my_action = defaction(css_class) { emit <| $K(css_class).append("<span>!!</span>"); |> } 

but this starts the console message "css_class not defined".

How to configure a parameter so that I can use it in the "emit" block?

+4
source share
1 answer

There is a problem with the environment that is still resolved. Right now, just assign a variable to your parameter and your emit will see this. So something like this:

 my_action = defaction(css_class) { my_class = css_class; emit <| $K(my_class).append("<span>!!</span>"); |> } 
+5
source

Source: https://habr.com/ru/post/1346842/


All Articles