8 #include <Wt/WApplication>
10 #include <Wt/WContainerWidget>
12 #include <Wt/WPushButton>
22 setTitle(
"Javascript example");
40 new WText(
"<h2>Wt Javascript example</h2>"
41 "<p>Wt makes abstraction of Javascript, and therefore allows you"
42 " to develop web applications without any knowledge of Javascript,"
43 " and which are not dependent on Javascript."
44 " However, Wt does allow you to add custom Javascript code:</p>"
46 " <li>To call custom JavaScript code from an event handler, "
47 "connect the Wt::EventSignal to a Wt::JSlot.</li>"
48 " <li>To call C++ code from custom JavaScript, use "
49 "Wt.emit() to emit a Wt::JSignal.</li>"
50 " <li>To call custom JavaScript code from C++, use "
51 "WApplication::doJavascript() or Wt::JSlot::exec().</li>"
53 "<p>This simple application shows how to interact between C++ and"
54 " JavaScript using the JSlot and JSignal classes.</p>", root());
59 WPushButton *amountButton =
new WPushButton(
"Change ...", root());
60 amountButton->setMargin(10, Left | Right);
64 WPushButton *confirmButton =
new WPushButton(
"Pay now.", root());
65 confirmButton->setMargin(10, Top | Bottom);
98 int main(
int argc,
char **argv)
Popup * promptAmount_
Popup for changing the amount.
void confirmed()
The user has confirmed the payment.
WText * currentAmount_
WText for showing the current amount.
void setAmount(std::string amount)
Set the amount to be payed.
WApplication * createApplication(const WEnvironment &env)
int main(int argc, char **argv)
Popup * confirmPay_
Popup for paying.
JavascriptExample(const WEnvironment &env)
Create the example application.
An example showing how to interact custom JavaScript with Wt stuff.