Hi there,
I've got a little problem to link a button to a dynamic page by using the query results of my backend module. This is the first time that I try to code something just to try to get a faster loadtime of the site. So I wrote a backend module:
// Filename: backend/dataService.jsw (web modules need to have a .jsw extension) import wixData from 'wix-data' export function getTurnierkalender(){ return wixData.query('Turnierkalender') .gt('turnierDatum', new Date()) .ascending('turnierDatum') .limit(3) .find() .then((results) => { return results.items; }); }
now I try to fill my result into textfields of my page problem ist the link to my dynamic item page. the results fieldname has dashes in it. In the Pages Code I get the error when I use a dash in the fieldname so can you give me a hint how to refer to the results.fieldname that has dashes in it?
$w.onReady( function() { getTurnierkalender() .then( (results) => { $w('#vaDd').text = "" + results[0].vaDd $w('#monat').text = results[0].monat $w('#title').text = results[0].title $w('#subtitle').text = results[0].subtitle $w('#wettspielform').text = results[0].wettspielform $w('#startform').text = results[0].startform $w('#spielform').text = results[0].spielform $w('#vorgabenwirksam').text = results[0].vorgabenwirksam $w('#abschlagszeit').text = results[0].abschlagszeit $w('#linkTurnier').link = results[0].link-Turnierkalender-monat-vaDd-title $w('#text9').text = "" + results[1].vaDd $w('#text10').text = results[1].monat $w('#text8').text = results[1].title $w('#text7').text = results[1].subtitle $w('#text6').text = results[1].wettspielform $w('#text5').text = results[1].startform $w('#text4').text = results[1].spielform $w('#text3').text = results[1].vorgabenwirksam $w('#text2').text = results[1].abschlagszeit $w('#text18').text = "" + results[2].vaDd $w('#text19').text = results[2].monat $w('#text17').text = results[2].title $w('#text16').text = results[2].subtitle $w('#text15').text = results[2].wettspielform $w('#text14').text = results[2].startform $w('#text13').text = results[2].spielform $w('#text12').text = results[2].vorgabenwirksam $w('#text11').text = results[2].abschlagszeit }) })
Would be great to get some help :-)
cheers Thomas
In JavaScript, you can access such object properties with the bracket notation:
results[0]['link-Turnierkalender-monat-vaDd-title']
Hey @Tomer (Wix) would you be willing to help me with something else? I'm currently struggling to limit the number of characters displayed in a text box on a database connected repeater, I can't get it working... This is my code, any ideas?
$w.onReady(function () { $w("#eventphotos").onReady(() => { let text = $w("#eventphotos").getCurrentItem().unsearchedrepdescrip; if (text.length > 100) { text = text.substring(0,97) + '...'; } $w("#unsearchedrepdescrip").text = text; }); })
Thank you so much for responding to me!
Just had to say thank you!!! I was struggling with this and COULD NOT find the answer until this post.