Blueforcer Well-Known Member Licensed User Longtime User Jul 12, 2019 #1 Hello, i want to place a spinner on my side wich needs a javascript to run. This javascript call is right before the body ends <script src="../plugins/jquery-spinner/js/jquery.spinner.js"></script> The Spinner works fine if i place it hardcoded in the HTML file, but if i use setHTML with a websocket to place the exact same code into a div, the spinner doesnt work anymore. What i have to do?
Hello, i want to place a spinner on my side wich needs a javascript to run. This javascript call is right before the body ends <script src="../plugins/jquery-spinner/js/jquery.spinner.js"></script> The Spinner works fine if i place it hardcoded in the HTML file, but if i use setHTML with a websocket to place the exact same code into a div, the spinner doesnt work anymore. What i have to do?
OliverA Expert Licensed User Longtime User Jul 12, 2019 #2 Try Code: Copy ws.eval($"$.getScript("../plugins/jquery-spinner/js/jquery.spinner.js")"$, Null) Sources: https://stackoverflow.com/questions...nserted-with-innerhtml#comment1020755_1197585 https://api.jquery.com/jQuery.getScript/ Upvote 0
Try Code: Copy ws.eval($"$.getScript("../plugins/jquery-spinner/js/jquery.spinner.js")"$, Null) Sources: https://stackoverflow.com/questions...nserted-with-innerhtml#comment1020755_1197585 https://api.jquery.com/jQuery.getScript/
Blueforcer Well-Known Member Licensed User Longtime User Jul 15, 2019 #3 Thank you this works in that case. But not always. For example: I have some elements (e.g a dropdown) inside a div with ID "content" pushed by setHTML. as soon as i have the sub content_Click (Params As Map) the elements doesnt work anymore. even if i load every js with getScript again it looks like the b4j event replaces or overwrite the event to show the dropdownmenu or something like that Last edited: Jul 15, 2019 Upvote 0
Thank you this works in that case. But not always. For example: I have some elements (e.g a dropdown) inside a div with ID "content" pushed by setHTML. as soon as i have the sub content_Click (Params As Map) the elements doesnt work anymore. even if i load every js with getScript again it looks like the b4j event replaces or overwrite the event to show the dropdownmenu or something like that
OliverA Expert Licensed User Longtime User Jul 15, 2019 #4 Blueforcer said: I have some elements (e.g a dropdown) inside a div with ID "content" pushed by setHTML. Click to expand... Since you have to declare this statically in you B4J code (via a something like: Dim content As JQueryElement), why don't you just also put it statically in you HTML and use the display property to show/hide the element as needed? Code: Copy 'To hide the div with id content content.SetProp("display", "none") 'To show the div content.SetProp("display", "block") You could also use the visbility property Links: https://www.w3schools.com/cssref/pr_class_display.asp https://www.w3schools.com/cssref/pr_class_visibility.asp Upvote 0
Blueforcer said: I have some elements (e.g a dropdown) inside a div with ID "content" pushed by setHTML. Click to expand... Since you have to declare this statically in you B4J code (via a something like: Dim content As JQueryElement), why don't you just also put it statically in you HTML and use the display property to show/hide the element as needed? Code: Copy 'To hide the div with id content content.SetProp("display", "none") 'To show the div content.SetProp("display", "block") You could also use the visbility property Links: https://www.w3schools.com/cssref/pr_class_display.asp https://www.w3schools.com/cssref/pr_class_visibility.asp
Blueforcer Well-Known Member Licensed User Longtime User Jul 15, 2019 #5 i have declare it. The content needs to be dynamic because its an appstore and will build according apps in a online Database. So its not possible to hardcode each element. But since i need to catch every button click inside each "App"-Element I need to do it by the whole content click event and select the click by the target. Upvote 0
i have declare it. The content needs to be dynamic because its an appstore and will build according apps in a online Database. So its not possible to hardcode each element. But since i need to catch every button click inside each "App"-Element I need to do it by the whole content click event and select the click by the target.
OliverA Expert Licensed User Longtime User Jul 15, 2019 #6 You can create a callback via ws.Eval and JavaScript. For example, an elements click event can be set via Code: Copy Dim elementID As String = "content" Dim clickJS As String = $" $("#${elementID}").on("click",function(){ b4j_raiseEvent('${elementID}_click', {'callerID' : '${elementID}'}); });"$ ws.Eval(clickJS, Null) then Code: Copy Sub content_click (Params As Map) Log(Params) End Sub should log an callerID map entry. Notes: 1) Untested code 2) You've placed an element with ID "content" via setHTML 3) The HTML element with ID "content" needs to have a click event for this to work Upvote 0
You can create a callback via ws.Eval and JavaScript. For example, an elements click event can be set via Code: Copy Dim elementID As String = "content" Dim clickJS As String = $" $("#${elementID}").on("click",function(){ b4j_raiseEvent('${elementID}_click', {'callerID' : '${elementID}'}); });"$ ws.Eval(clickJS, Null) then Code: Copy Sub content_click (Params As Map) Log(Params) End Sub should log an callerID map entry. Notes: 1) Untested code 2) You've placed an element with ID "content" via setHTML 3) The HTML element with ID "content" needs to have a click event for this to work