daattali / shinyjs

💡 Easily improve the user experience of your Shiny apps in seconds
https://deanattali.com/shinyjs
Other
728 stars 119 forks source link

`extendShinyjs(script = htmlDependency(...), functions = ...)` support #254

Open mmuurr opened 1 year ago

mmuurr commented 1 year ago

I'm wondering if there's a simple way to specify the script file holding {shinyjs} 'extension' functions as an {htmltools} htmlDependency object, using then the absolute file resolution codepath of that dependency.

I realize addResourcePath() does something similar already, but as I write some standardized wrappers I was just curious if htmlDependency() had ever been considered :-)

Cheers and thanks!

daattali commented 1 year ago

I haven't thought of this before, so it's not supported. The only reason it's not supported is because this function was written many years ago before I understood how htmlDependency() works. This would be a good idea if anyone wants to try to implement it.

daattali commented 1 year ago

@mmuurr This should now be supported, you can use the script argument with an htmlDependency. Can you please let me know if it works for you?

Note to self: before closing the issue, update documentation anywhere that addResourcePath is used or where extendShinyjs is used

mmuurr commented 1 year ago

@daattali,

This should not be supported ...

I assume that's a typo and it actually should be, "This should now be supported"; correct?

(It's a shame that two dramatically different meanings are separable by only one character :-))

daattali commented 1 year ago

I should not be writing messages (or even worse, coding) at 4:50am... yet here we are. Hopefully the code was better than the message. Can you please verify that this works for you?

mmuurr commented 1 year ago

Yup, this seems to be working for me now; thanks!

(I still always struggle with the various options of htmlDependency() itself and how to get the output HTML tags to what I want, but that's {htmltools}' issue and the challenges that come with heavily-overloading a single function's optional parameters :-| )

daattali commented 1 year ago

Oh I also do! Every single time I need to use htmlDependency(), I do a github serach through my own repos to see how to use it. Every single time.