Open an URL in new tab

Hello,

I want to open an URL to a new tab from the interface page. I have created a custom widget to achieve this. This widget has a setting web_url that we can set in the widget configuration from the page.

I am setting a hard-coded URL in the widget setting as of now. I am facing one issue here. I can get the value set in the widget configuration in main.js code. I am returning the value from main.js, but I cant get the value in frontend.js. Below is my code.

Could you please let me know if I am doing something wrong here?

main.js
return {
get_template_data: function() {
var webLink = widget.get_setting(‘web_url’);
cs.log('webURL = '+ webLink);

	return 
	{
		web_link : webURL
	} 
},

get_settings: function() {
	return {
		web_url: {
			main_label: "Web URL to Load",
			base_format: 'string'
		}
	};
}

}

frontend.js
export default {

mounted: function()	{
	console.log('webLink = '+ this.web_link);

	if(this.web_link)
	{
		window.open(this.web_link, '_blank');
	}

	$(document).ready(function(){		
		console.log('webLink 2 = '+ this.web_link);
	});
},

methods: {

}

}

Thanks in advance.

Best Regards,
Mayur

Hi, you just have a typo in your get_template_data return code. webURL should be webLink instead:

	return 
	{
		web_link : webLink
	}

Thank you for your reply. I was using different variable before. I corrected the variable but still facing the same issue. The value of this.web_link is undefined in frontend.js.

Nothing else stands out as incorrect in the above. Could you paste your latest version of the code, in case there are other differences since then?