getValue (bric UI Element)

Hi there,

I have read the dev docs as much as I can find, and I see we can setValue of any UI element belonging to the bric from anywhere in the js file. But I don’t see how we can getValue???

For clarity, an example of the use case I currently have.
I need to show / Hide a UI element based on the value of another UI element, so I need it’s value for a conditional.

// when one UI elements value changes this function fires.
function SetTheTarget(value,stringValue,attrName)
{
	var anotherUIElementVisibility = true
	// How to get some other UI element value from this same bric ?????
	if (someOtherElementValue == someArbitaryValue) { 
		var anotherUIElementVisibility = false
	}
	
	window.webkit.messageHandlers.setUIHidden.postMessage(
		JSON.stringify({
			"attr": "ten-ton-data",
			"hidden": anotherUIElementVisibility
		})
	);
}
1 Like

For completeness, simplicity, and brevity. How would you get the current value of any one of your Brics UI elements inside the init function?

You need to store this yourself within the Brics HTML and then retrieve it when you need it, using JS, data attributes is a good way around this. Download some of our free Brics to get examples of how we have done this in.

If you place all of this stored data onto a html tag with the class remove-on-export this will be removed when you export to keep the output clean. There are various helper classes which you can read about here.

I hope that helps.

@doobox wowsers! This is exciting, I hope this means we may see Doobox creating brics? I bought every single one of your stacks, they are awesome!

5 Likes

Thanks Norm. Yeah, I can do that. Just wanted to be sure I wasn’t missing an api call :+1:

1 Like

Maybe. Blocs is a fairly complete package as it stands, capable of almost anything out of the box
I have a few ideas cooking.

8 Likes

That will be interesting to see, although some of the Doobox bangers would be good to see Spin, Vegas, Flood, Obscure

I’m a big fan of Blocs’ built-in features and rarely need to use any third-party plugins. However, when a developer understands what you’ve just said, it’s incredibly exciting and promising! I’m eagerly looking forward to seeing your ideas come to life!

5 Likes

Now this is a sight I’m happy to see !

Welcome @doobox to blocs. Huge fan of your work……can’t wait to see what you bring!

This is a great time for Blocs

7 Likes