Page 1 of 1
Set toast message on select
Posted: Wed Oct 05, 2022 5:10 pm
by philmills
On a slight tangent from this topic, hence the new topic:
viewtopic.php?t=54275
Lets say for example my dropdown contains values 1, 2 or 3 and I want a different message displayed based on each value. How do I trigger PHPMaker's alert system from within the jquery code?
if (this.value == "1"){
//show $this->setMessage(Language()->phrase('MyMessage _1'));
}
if (this.value == "2"){
//show $this->setMessage(Language()->phrase('MyMessage_2'));
}
if (this.value == "3"){
//show $this->setMessage(Language()->phrase('MyMessage_2'));
}
Re: setMessage on select
Posted: Wed Oct 05, 2022 5:46 pm
by mobhar
You may try:
if (this.value == "1")
ew.alert(ew.language.phrase("MyMessage _1"));
In addition, make sure you have already defined the MyMessage_1
phrase either in Language_Load server event using setPhrase
method with third param = true
, or in .xml language file with param client="1"
, so that the phrase will be able read from client-side.
Re: Set message on select
Posted: Wed Oct 05, 2022 8:35 pm
by philmills
Thanks, this is working
What also is correct syntax for displayimng the mesage using the bootstrap toast (which looks more polite for some purposes)?
Re: Set message on select
Posted: Wed Oct 05, 2022 9:59 pm
by philmills
I figured it out
if (this.value == "1"){
ew.toast({title:'Info', body:ew.language.phrase("MyMessage_1"), autohide:'false', delay:'5000', animation:'true', class:'toast bg-warning fade show'});
}
if (this.value == "2"){
ew.toast({title:'Info', body:ew.language.phrase("MyMessage_2"), autohide:'false', delay:'5000', animation:'true', class:'toast bg-warning fade show'});
}
if (this.value == "3"){
ew.toast({title:'Info', body:ew.language.phrase("MyMessage_3"), autohide:'false', delay:'5000', animation:'true', class:'toast bg-warning fade show'});
}