I try to hide a getSubsrcibers form connected to a switch (so when you select the switch the box appears and when you select it again it disappears). This is the code:
export function switch1_click(event) {
if ($w('#switch1').checked)
$w('#getSubscribers1').collapse()
else
$w('#getSubscribers1').expand()
}
Now the strange things is: the code works and if I subscribe my email gets added to the form/dbase. BUT, in the code panel I get the notification
'collapse' does not exist on 'getSubscribers1' .
Can anyone explain me why and if I need to change something?
Thanks in advance!
Hey Mark! I tried the functionality on the test page you've shared. Everything seems to work as expected.
Sometimes when a new feature/component is being released the IDE (your code platform) still shows some errors due to its unfamiliarity with the new element. Thanks for letting us know regarding this, I'll make sure it is fixed but rest assure it does not affect your site performance and you can just disregard this error. Doron.
Mark, just in case you are wondering, setting up your own subscribers form is easy.
I have one below through code that is on the same page as a contact us form and the code is below,
(A triggered email is sent to the user after the form is submitted and saved, hence the onAfterSave.)
import wixCRM from 'wix-crm'; $w.onReady(function() { $w("#PublicContactUs").onAfterSave(() => { let name = $w('#publiccontactName').value; let email = $w("#publiccontactEmail").value; let subject = $w("#publiccontactSubject").value; let message = $w("#publiccontactMessage").value; let label = ["Contacted Us"]; wixCRM.createContact({ "name": name, "emails": [email] }) .then((contactId) => { // Need to use the triggered email name return wixCRM.emailContact('publiccontactus', contactId, { "variables": { // Need to use the triggered email variable names "name": name, "email": email, // << - correct variable is email not emails "subject": subject, "message": message } }); }) .catch((err) => { // handle the error if the email wasn't sent console.log(`Error: ${err}`); }); }); }); $w("#NewSubscriber").onAfterSave(() => { let name = $w("#newsubscriberName").value; let email = $w("#newsubscriberEmail").value; let privacyPolicy = $w("#newsubscriberPrivacy").value; let label = ["Subscribed"]; wixCRM.createContact({ "name": name, "emails": [email] }) .then((contactId) => { // Need to use the triggered email name return wixCRM.emailContact('newsubscriber', contactId, { "variables": { // Need to use the triggered email variable names "name": name, "email": email, // << - correct variable is email not emails //"privacyPolicy": privacyPolicy << - not defined in the triggered email } }); }) .catch((err) => { // handle the error if the email wasn't sent console.log(`Error: ${err}`); }); });
Hey Mark!
What kind of component is $w('#getSubscribers1')? Please share a link to your site and specify on which page the code exists.
Rest assured that only authorized personnel are able to inspect your site and see your editor.
Doron.