-
-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation request: Need to call useShinyjs within the app session #182
Comments
I don't fully understand the issue - can you try to provide a small code
sample showing the problem? As long as the UI of an app calls useShinyjs
once, that's all that's needed, I don't follow what happens in your case
…On Thu, Apr 18, 2019, 09:22 ambevill ***@***.*** wrote:
I wrote a package myapp that uses shinyjs. myapp defines the UI,
including calling shinyjs::useShinyjs(). The session using myapp only
needs to pass the UI to shiny::runApp().
The problem is that the session never actually calls useShinyjs when myapp
is loaded, so the shinyjs javascript functions aren't available from the
shiny server. I guess the call to shiny::addResourcePath isn't persistent
within the session.
Based on other open issues, it seems like useShinyjs is probably
unavoidable. But the documentation should mention that useShinyjs should
be called again within the session running the app, even if it was called
in the myapp package.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#182>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAHIQFE6RSXEABYYMHA76X3PRBY2TANCNFSM4HG425AQ>
.
|
Thanks for your patience. The issue has to do with packaged apps, so I had to throw together a demo package. Here's a MWE:
MWE package repo is here. My recommendation is to add a note about this use case in the shinyjs README.md and the doc here. P.S. Thanks for your hard work supporting this package---I've used it in all of my recent shiny apps. |
I see what you mean! That is a great reprex, thank you for your effort to make it so clear and for your debugging to see what the problem is. You're right, if you just call So the takeaway here is that the UI function needs to be actively called, you can't just use a previously executed UI as a variable, it must be called as a function, right? I think that would be a more advisable suggestion than to say "you should call useShinyjs() in the end user app". What do you think? |
Sounds good! And I think in general it should be clear that For what it's worth, I haven't really seen an elegant way to automatically call |
I've been thinking that .onLoad might be the right approach but wanted to really think about it more to ensure there weren't any weird cases I wasn't thinking about. If shiny approves that method, then that makes me feel much more comfortable with that. I do want to do a lot of testing around this so I'll get around to it hopefully within the week. Thanks a lot for your help |
Unfortunately that suggestion doesn't fix the issue. I tried placing the I do think that the safest thing to do is tell users that |
🤦♂️ my bad, of course the |
Yes, exactly. I still appreciate your effort here, this was a usecase I haven't thought about and haven't run into so it was important to go through it. Feel free to add a short note in the docs |
Fixed with 5795e52 |
I wrote a package
myapp
that uses shinyjs.myapp
defines the UI, including callingshinyjs::useShinyjs()
. The session usingmyapp
only needs to pass the UI toshiny::runApp()
.The problem is that the session never actually calls
useShinyjs
whenmyapp
is loaded, so theshinyjs
javascript functions aren't available from the shiny server. I guess the call toshiny::addResourcePath
isn't persistent within the session.Based on other open issues, it seems like
useShinyjs
is probably unavoidable. But the documentation should mention thatuseShinyjs
should be called again within the session running the app, even if it was called in themyapp
package.The text was updated successfully, but these errors were encountered: