An example showing how to interact custom JavaScript with Wt stuff.
More...
#include <JavascriptExample.h>
An example showing how to interact custom JavaScript with Wt stuff.
Definition at line 24 of file JavascriptExample.h.
◆ JavascriptExample()
JavascriptExample::JavascriptExample |
( |
const WEnvironment & |
env | ) |
|
Create the example application.
Definition at line 17 of file JavascriptExample.C.
20 setTitle(
"Javascript example");
29 this, std::placeholders::_1));
38 root()->addWidget(cpp14::make_unique<WText>(
"<h2>Wt Javascript example</h2>" 39 "<p>Wt makes abstraction of Javascript, and therefore allows you" 40 " to develop web applications without any knowledge of Javascript," 41 " and which are not dependent on Javascript." 42 " However, Wt does allow you to add custom Javascript code:</p>" 44 " <li>To call custom JavaScript code from an event handler, " 45 "connect the Wt::EventSignal to a Wt::JSlot.</li>" 46 " <li>To call C++ code from custom JavaScript, use " 47 "Wt.emit() to emit a Wt::JSignal.</li>" 48 " <li>To call custom JavaScript code from C++, use " 49 "WApplication::doJavascript() or Wt::JSlot::exec().</li>" 51 "<p>This simple application shows how to interact between C++ and" 52 " JavaScript using the JSlot and JSignal classes.</p>"));
55 = root()->addWidget(cpp14::make_unique<WText>(
"Current amount: $" +
59 root()->addWidget(cpp14::make_unique<WPushButton>(
"Change ..."));
60 amountButton->setMargin(10, Side::Left | Side::Right);
62 root()->addWidget(cpp14::make_unique<WBreak>());
65 root()->addWidget(cpp14::make_unique<WPushButton>(
"Pay now."));
66 confirmButton->setMargin(10, Side::Top | Side::Bottom);
71 confirmButton->clicked().connect(
confirmPay_->show);
void confirmed()
The user has confirmed the payment.
WText * currentAmount_
WText for showing the current amount.
std::unique_ptr< Popup > promptAmount_
Popup for changing the amount.
void setAmount(std::string amount)
Set the amount to be payed.
std::unique_ptr< Popup > confirmPay_
Popup for paying.
◆ confirmed()
void JavascriptExample::confirmed |
( |
| ) |
|
|
private |
The user has confirmed the payment.
Definition at line 89 of file JavascriptExample.C.
91 root()->addWidget(cpp14::make_unique<WText>(
"<br/>Just payed $" +
std::unique_ptr< Popup > promptAmount_
Popup for changing the amount.
◆ setAmount()
void JavascriptExample::setAmount |
( |
std::string |
amount | ) |
|
|
private |
Set the amount to be payed.
Definition at line 77 of file JavascriptExample.C.
80 confirmPay_->setMessage(
"Are you sure you want to pay $" + amount +
" ?");
WText * currentAmount_
WText for showing the current amount.
std::unique_ptr< Popup > promptAmount_
Popup for changing the amount.
std::unique_ptr< Popup > confirmPay_
Popup for paying.
◆ confirmPay_
std::unique_ptr<Popup> JavascriptExample::confirmPay_ |
|
private |
◆ currentAmount_
WText* JavascriptExample::currentAmount_ |
|
private |
◆ promptAmount_
std::unique_ptr<Popup> JavascriptExample::promptAmount_ |
|
private |
The documentation for this class was generated from the following files: