chef 3746 Posted May 30, 2019 Share Posted May 30, 2019 (edited) I am not familiar with the new javascript plugin architecture. Could somebody recommend some articles to read so I understand what we are doing the we use 'define([]), function'. I see that the 'view' event for the page load returns the page data. Thanks Ben Edited May 30, 2019 by chef Link to comment Share on other sites More sharing options...
chef 3746 Posted May 30, 2019 Author Share Posted May 30, 2019 I think I'm asking the wrong question. When I add this to my plugin.cs I expect to see my JS file loaded into the server. This is not happening. This is my GetPages Function.cs public IEnumerable<PluginPageInfo> GetPages() { return new[] { new PluginPageInfo() { Name = "MainPluginConfigurationPage", EmbeddedResourcePath = GetType().Namespace + ".Configuration.MainPluginConfigurationPage.html", EnableInMainMenu = true, DisplayName = "Home Automation" }, new PluginPageInfo() { Name = "MainPluginConfigurationPageJS", EmbeddedResourcePath = GetType().Namespace + ".Configuration.mainPluginConfigurationPage.js" } }; } Both Files are in the proper namespace, and are set to Embedded Resource And yet hen the Server Load, it doesn't load the JS file? I would expect to see the configuration load here: Like the rest of the plugins do here: Currently the only reason my plugin loads in because there is Jquery in a script tag, which I would like to move away from, and make sure its set up properly like all the other plugins. Link to comment Share on other sites More sharing options...
chef 3746 Posted May 30, 2019 Author Share Posted May 30, 2019 You need to add your JS as a data-controller in your page, also you dont need to supply the full HTML just the DIV contents. See an example here: https://github.com/faush01/playback_reporting/blob/develop/playback_reporting/Pages/custom_query.html data-controller="__plugin/custom_query.js" this is the name of the page you set up in you GetPages() new PluginPageInfo { Name = "custom_query.js", EmbeddedResourcePath = GetType().Namespace + ".Pages.custom_query.js" }, Thank you, that has been driving me NUTZZZZ! Link to comment Share on other sites More sharing options...
chef 3746 Posted May 30, 2019 Author Share Posted May 30, 2019 (edited) @@TeamB YES! Thank you very very much! Edited May 30, 2019 by chef Link to comment Share on other sites More sharing options...
chef 3746 Posted May 31, 2019 Author Share Posted May 31, 2019 Is it bad form to still use JQuery in emby plugins? Some Github repos are still legacy. Link to comment Share on other sites More sharing options...
Luke 37098 Posted May 31, 2019 Share Posted May 31, 2019 You can still use it, but we are trying to gradually eliminate it from core pages. Link to comment Share on other sites More sharing options...
chef 3746 Posted June 1, 2019 Author Share Posted June 1, 2019 You can still use it, but we are trying to gradually eliminate it from core pages. @@Luke All I can say after the last 48 hours, and calling into work sick.. because code... is Javascript can be really hard. I see why people say Jquery makes you soft... better get a good understanding of what JQuery is doing 'under the hood' because it's all sudo. Link to comment Share on other sites More sharing options...
Luke 37098 Posted June 1, 2019 Share Posted June 1, 2019 What it originally set out to do to normalize browser differences is no longer needed these days. Link to comment Share on other sites More sharing options...
chef 3746 Posted June 1, 2019 Author Share Posted June 1, 2019 (edited) @@Luke ...and 56 hours later I have finally become intermediate! hardest thing to do is targeting child and parent nodes in the DOM when making element on the fly. for some reason using querySelectorAll is finicky on dynamically created elements. I had all my data attributes in parent nodes that were hard to reach when made on the fly. I had to add event listeners on the containers and use 'closest('div > .className')' which contained data attributes, and catch them on the bubble up. Yeah I used the phrase "bubble up". and also know when to stop Propagation of events too... See intermediate! Edited June 1, 2019 by chef Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now