Get reference to Root element in custom element using svelte - custom-controls

When debugging svelte component compiled as a custom control I can see in the compiled code function instance($$self, $$props, $$invalidate) where $$self is the actual "root" element of the component.
Trying to get this $$self in the code leads to an compile time error..
What should I do to get the reference to the shadowRootNode in Svelte, I need it when I want to dispatch a custom event from my custom control e.g 'PersonPicked'

Related

In polotly.js, how may I get call a javascript callback called when a slider is changed, and get its current value as argument?

I want to build a web page in plotly.js for plotting a mathematical function depending on some parameters. I want the user to be able to change it using a slider.
For doing this, I need to call my own javascript function (to recalculate the points of the graph), get the current value of the slider and update the graph.
I've looking at the examples in
https://plotly.com/javascript/sliders/
but none of them does what I need, and the documentation
at
https://plotly.com/javascript/reference/layout/sliders/
is not clear at all. It seems that I need to set the "method" property (also "args"). It says
"Sets the Plotly method to be called when the slider value is changed. If the skip method is used, the API slider will function as normal but will perform no API calls and will not bind automatically to state updates. This may be used to create a component interface and attach to slider events manually via JavaScript."
What does it mean?
I already have an application using plotly dash at
https://github.com/pdenapo/normal_bivariada/blob/main/normal_bivariada_interactiva.py
and it is very easy to do using #app.callback. However,
I want to do the same in javascript (since I want to run it on a web server, where I cannot run a python application).
¡Many thanks for any help!

Tealium: Fire JavaScript pixel on button click

I'm a new Tealium user and I have the following problem:
I have a JavaScript pixel that has to be implemented on a certain button click. I created a custom container tag and I added the Javascript code by editing the tag's template like this:
Apart of that I have this code that runs when I click the button:
So, I added this load rule to the tag:
The problem is that I don't see that the tag fires when I click the button.
Can you help me to find what is wrong?
It looks like the link event data object is being set via a Tealium extension (but there is insufficient information in the question to be sure). If so, the scope and timing of that extension are critical for load rules processing. Make sure the variable event_name is getting set in an extension with a scope that allows execution before load rules. For a link event, this is typically “All Tags” scope and execution order is “Before Load Rules”.
Take a look at the Tealium extension docs for more information on Scope and Execution Order: https://community.tealiumiq.com/t5/iQ-Tag-Management/Extensions/ta-p/13649#toc-hId-1361707577
Alternatively, make sure that your custom tag is coded properly and validate that it works correctly. It’s possible that you need to update the u.ev variable (defines which event types the tag can run on) and/or need to provide more instructions in the u.loader_cb callback statement: https://community.tealiumiq.com/t5/iQ-Tag-Management/Tealium-Custom-Container-Tag/ta-p/14015
Debugging: https://community.tealiumiq.com/t5/iQ-Tag-Management/Debugging/ta-p/30675

How do you add JS assets to a BackEnd formWidget in Child Form in OctoberCMS?

I am not sure if I am adding my JS assets correctly and would like some advice if I am not.
In octoberCMS I have created a custom formWidget that uses the Google Maps API.
I am using my formWidget inside a child form that is rendered via AJaX as a modal when required.
If I use the following code in my widget class:
public function loadAssets(){
$this->addJs("http://maps.googleapis.com/maps/api/js?key=myappkeyhere&libraries=places");
$this->addJs('js/geocomplete/jquery.geocomplete.min.js');
$this->addJs('js/addressinput.js');
$this->addCss('css/addressinput.css');
}
The JS loads with the Page load and not when the widget is rendered. This produces these issues:
The google-maps API returns an error saying it has been loaded multiple times.
Events tied to DOM elements in the child fail since the elements are not in the DOM until the form is called.
The workaround I am using is to embed my JS into the formWidget partial.
Is there a way to make the addJS method work for the formWidget when it is part of a child form?
After some investigation, I realised that my formWidget using the addJs() method would make the widget JS available globally to the entire page even before the formWidget existed or was even needed.
While I could have created an elaborate, fancy JS involving listeners for DOM insertions and blah blah blah, this was not ideal (mainly because the widget properties change based on implementation).
The quickest/safest way to include JS that is tightly bound to a complex formWidget is to include it in the partial. This ensures the form widget will work properly both in a standalone form and in situations where the widget is part of child form that is created via an Ajax load.
(If you know of a better way please let me know)

Could find kendoNumericTextBox by class name

I am trying to attach change event handler to the instance of kendoNumercTextBox.
I am able to get the instance of kendoNumercTextBox control using its ID, however Im not able to get the instance using class name
here is the code http://dojo.telerik.com/emIWa/11
NOTE
I DO NOT want to attach event handler at the time of instantiating
the control. I want to get the existing instance and then attach the
event handler.
Also i am actually using Kendo ASP.NET MVC, however
dojo doesn't allow me to write cshtml so i am using kendo UI for
the demo purpose above. But i think end result would be same.
The NumericTextBox is created like below in cshtml
#(Html.Kendo().NumericTextBoxFor(x =>x.numerictextbox).HtmlAttributes(new {#class = "MyClass"}))
You need to use a more specific jQuery selector. This for example will get the correct element which is the one with the data-role attribute:
var numerictextboxByClassName = $(".MyClass [data-role]")
If you use the developer tools in your browser to inspect the text box, you'll see that 'MyClass' is on several elements that comprise the widget, hence the need to be more specific. It is also worth noting that the handler will only attach to the first instance found using the selector so this method cannot be used to attach a handler to several such controls at the same time.

invoke manually button click event in c++ builder

Using c++ builder borland (bcb6).
I wish to invoke manually button click event. I did:
FMap->bbDoneInClick(NULL);
While Done button located on the FMap form, but something went wrong with that.
Do I need to call bbDoneInClick with different parameters and not with NULL ?
Instead of NULL use the Form1 or the bbDone itself ...
it depends on the event code itself how it uses the Sender parameter
Also you can call the event handler safely only if the form is already created
if it does not access Canvas you can use it even in TForm1::TForm1 constructor
if it does you need to take care of not using it prior to OnShow or OnActivate
to avoid VCL problems or App crashes
for common handlers it is sufficient to use main window ... (I use this instead of NULL)
if you have single even handler for multiple components then the even is usually deciding the operation or target from the Sender parameter so in that case you need to pass the pointer to component itself

Resources