Access UI element values within a Plugin?
Hi, I created a Plugin with text fields. This Plugin sends a websocket to the webserver that then sends http requests to a different endpoint. I got all the websocket and http request call code working, so that's not a problem. I just can't seem to access the values of the UI elements in the Plugin.
I checked https://wiki.totaljs.com/jcomponent/07-plugins and saw that I can WATCH when the values change, but I just need the values when I click a button.
Example accessing text value within a component in Flow UI. Component name: test Element name: name
GET("settings.test.name");
I'm trying not to use the anonymous scopes, so my question is what path should I access to get values of UI elements' values in a plugin using the GET method.
Can you show the html you have? What do you mean by "text field", is it textbox or input component??
In the current case, it's a J-Input, but I might use different types of jComponents like jCodemirror.
Code: https://pastebin.com/WQLktFyB
Receiving server response via Event Listener works well. I just need to know how to modify the j-input and j-codemirror values via the SET() method in the example.
For this <div data---="input__comment__type:string">Comments</div> simple GET('comment') should work.
BUT i would strongly recomend to have an object for the form, something like requestform and use it like this
<div data---="modal__common.form__if:request;submit:request/submit;title:Confirmation Window" class="hidden">
...
<div data---="input__requestform.comment__type:string">Comments</div>
...
...
<div data---="codemirror__requestform.response__type:json;height:150;">response from server goes here.</div>
</div>
<script>
PLUGIN('request', function (exports) {
exports.submit = function () {
// get the form data
var form = GET('requestform');
// set the response to the form
SET('requestform.response', <response>);
I should've tried this haha I thought the values would be accessible in some other location for some reason.
Thanks!