JavaScript function that needs to wait?

My JavaScript code needs to get data from a function. The function is returning the data. I know because I see it via a console.log. However, the data it returns is too late for the function that needs it. How do I make it wait for the data? In this case, I need the property defaultColor: to wait for the function getCol().

    <script type="text/javascript">
		function getCol(col) {
			var dcol = '#'+col;
			console.log('default color: '+dcol);
			return dcol;

		  el: '.coloris',
		  swatches: [
		  defaultColor: getCol(),
		  onChange: function onChange(color) {
		  inline: true

		document.addEventListener('coloris:pick', event => {
		  console.log('New Color', event.detail.color);
		document.addEventListener('change', event => {
		  console.log('New Opener', event.detail);


Do you have access to the other function? Can you modify it?

That implies you do not have the ability to modify the other function. Probably we need more information. Are you familiar with HTML DOM Events?

I can modify the other function. All the code and even the caller. Note the caller is not a web app but a desktop app. I have some familiarity with the Dom. What other information would helpful? Thanks

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.