title basically sums it up but, I want to click a button in a Repeater and have a fieldkey in one of my data sets be added to the link that the button goes to. I'm new at coding on Wix so i apologize if my code is wayyyy off and or the Title
this seems to work kinda but only once and only for the first listing in the repeater
import wixData from 'wix-data';
export function carfax_click(event, $w) { carfaxUrl(); } function carfaxUrl (){ let vin = $w('#Vin').text; $w("#carfax").link = ("https://www.carfax.com/VehicleHistory/p/Report.cfx?partner=DLR_3&vin=" + vin) $w("#carfax").target = "_blank"; }
"vin" in this case is a cars vin number so that once its added it would go to that cars carfax page
Also: If some could show me the code to make a range slider with new slides that filters the repeater based on the range of number fieldkeys
Okay So I figured out how to get it to load in one click,
export function Vechicles_itemReady($item, itemData, index) { const carfax = $item("#carfax"); const vin = $item("#Vin"); carfax.src = carfax; vin.text = vin; carfax.onClick( (event) => {
{wixLocation.to('https://www.carfax.com/VehicleHistory/p/Report.cfx?partner=DLR_3&vin=' + vin.text)}})
}
But I also need it to open in a new tab, which i now know you have to use .target to do, I haven't been able to figure it out here were the ideas I had:
export function Vechicles_itemReady($item, itemData, index) {
const carfax = $item("#carfax");
const vin = $item("#Vin");
carfax.src = carfax;
vin.text = vin;
idea 1
carfax.onClick( (event) => {$item("#carfax").link = ('https://www.carfax.com/VehicleHistory/p/Report.cfx?partner=DLR_3&vin=' + vin.text).then(results => {let url = results.text; wixLocation.to(url)})
idea 2
carfax.onClick( (event) => {wixData.insert('https://www.carfax.com/VehicleHistory/p/Report.cfx?partner=DLR_3&vin=' + vin.text).then(results => { $item("#carfax").link = (results); $item("#carfax").target = "_blank"; // let url = $item("#carfax").link; //{wixLocation.to(url);}})
I've tried both and they don't work, can someone show me the correct way to do this
Haaazzzaaa It works! but with on small problem, I have to double click the button for it to take me to the url
export function Vechicles_itemReady($item, itemData, index) { const carfax = $item("#carfax"); const vin = $item("#Vin"); carfax.src = carfax; vin.text = vin; carfax.onClick( (event) => {$item("#carfax").link = ('https://www.carfax.com/VehicleHistory/p/Report.cfx?partner=DLR_3&vin=' + vin.text) }) }
If someone could let me know how to get it to load in one click that would be sweet
Okay well definitely is helpful to know that i need to use that, But I'm still so confused i have nor idea how to set this up this is the mess i came up with
export function Vechicles_itemReady($item, itemData, index) { const carfax = $item("#carfax"); const vin = $w('#Vin'); carfax.src = carfax.img; vin.text = vin.number; carfax.onClick( (event) => { vin.text = vin.number; $w("#carfax").link = ("https://www.carfax.com/VehicleHistory/p/Report.cfx?partner=DLR_3&vin=" + vin.number).toString(); $w("#carfax").target = "_blank"; } ); }
It doesn't work or do anything lol
If it's a repeater, then you should use: onItemReady:
https://www.wix.com/corvid/reference/$w.Repeater.html#onItemReady