Hi folks!
I currently have a repeater that's linked to a database that contains a headline, thumbnail, and excerpt for external news articles, and I have a URL field in the database, so that the thumbnail and headline will link to the article we're referencing.
As we all know, the photo database setting gives us the option to connect it the URL, but the textbox for the headline doesn't, so I added the following code to Velo on the page, hoping to reference the URL field:
import wixLocation from 'wix-location';
$w.onReady(function () {
$w('#NewsArticlesRepeater').onItemReady((selector, itemData, index) => {
$w('#ArticleTitle').onClick(() => {
wixLocation.to(itemData.url);
});
});
});
And it worked!
However, that link is opening in the same tab. And I want to add some code to force it to open in a new tab.
Can anyone help?
The link to the page on my website is: https://www.regularsmusical.com/news
Thanks in advance.
Warmly,
Miss Hazel xx
@LMeyer Any chance you could also help here?
First off I would change selector to $item and the call the text as $item("#ArticleTitle").
Right now there is not there is no way to change the target properties with wixLocation (at least as far as I know) reference this post for more info - https://www.wix.com/velo/forum/coding-with-velo/solved-how-to-open-in-new-tab-with-wix-location
Now, from memory if you click on a button with the .target and .link properties set it will open in a new page. So, perhaps place a transparent button over the top of your text and see how that goes. If I got that wrong as early dementia is setting in, I apologise.
Good luck!