Closed matsprea closed 4 years ago
I'd like the Tag Helper to also handle the JavaScript rather than the view having to do it. That means it needs to emit a script block that adds the jQuery event handlers, and it needs to only emit it once, and it needs to done in such a way that all instances of the Tag Helper are found (e.g. script runs on document load event).
:watch:
What about using a BodyTagHelper to check if we need to inject the js at the end of the page ?
I'm sorry, the last commit does not work as intended, I'll check it right now.
@matsprea using a BodyTagHelper
is probably a good way of doing this.
:watch:
I tried JavaScriptResources.GetEmbeddedJavaScript
but I always end up with the following exception, so I end up using GetManifestResourceStream
. Sorry, I clearly miss something here.
ArgumentNullException: Value cannot be null.
Parameter name: stream
System.IO.StreamReader..ctor(Stream stream, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean leaveOpen)
System.IO.StreamReader..ctor(Stream stream)
Microsoft.AspNet.Mvc.TagHelpers.Internal.JavaScriptResources.<>c__DisplayClass3_0.<GetEmbeddedJavaScript>b__0(String key)
System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
Microsoft.AspNet.Mvc.TagHelpers.Internal.JavaScriptResources.GetEmbeddedJavaScript(String resourceName, Func`2 getManifestResourceStream, ConcurrentDictionary`2 cache)
Microsoft.AspNet.Mvc.TagHelpers.Internal.JavaScriptResources.GetEmbeddedJavaScript(String resourceName)
ClickToShowTagHelper as for issue #21