本文整理汇总了C++中wt::WApplication::doJavaScript方法的典型用法代码示例。如果您正苦于以下问题:C++ WApplication::doJavaScript方法的具体用法?C++ WApplication::doJavaScript怎么用?C++ WApplication::doJavaScript使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wt::WApplication
的用法示例。
在下文中一共展示了WApplication::doJavaScript方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render
void Popup::render(Wt::WFlags<Wt::RenderFlag> flags) {
Wt::WApplication * app = Wt::WApplication::instance();
Wt::WString initFunction = app->javaScriptClass() + ".init_popup_" + id();
Wt::WStringStream stream;
stream
<< "{" << initFunction.toUTF8() << " = function() {"
<< " var self = " << jsRef() << ";"
<< " if (!self) {"
<< " setTimeout(" << initFunction.toUTF8() << ", 0);"
<< " }";
stream
<< " self.popup = new mapboxgl.Popup( {"
<< " closeButton: " << ToScript(closeButton_).toUTF8() << ", "
<< " closeOnClick: " << ToScript(closeOnClick_).toUTF8() << ", "
<< " anchor: " << ToScript(anchor_).toUTF8()
<< " });";
for (unsigned int i = 0; i < additions_.size(); i++) {
stream << additions_[i].toUTF8();
}
additions_.clear();
stream
<< " setTimeout(function(){ delete " << initFunction.toUTF8() << ";}, 0)};\n"
<< "}\n"
<< initFunction.toUTF8() << "();\n";
app->doJavaScript(stream.str());
}
示例2: tellClient
/// Call this to push a server side validation result to the client side (complete with message)
static void tellClient(WFormWidget* widget, const WString& value, Result validationResult) {
widget->setJavaScriptMember("serverValidationResult",
"{ value:" + value.jsStringLiteral() + ","
"valid:" + (validationResult.state() == WValidator::Valid ? "true," : "false,") +
"message:" + validationResult.message().jsStringLiteral() + "}");
Wt::WApplication* app = Wt::WApplication::instance();
app->doJavaScript( app->javaScriptClass() + ".WT.validate(" + widget->jsRef() + ");" );
}
示例3: toggleTheme
void MainWindow::toggleTheme() {
Wt::WApplication* app = Wt::WApplication::instance(); // Get the Wt::WApplication intstance for our thread
std::string oldTheme = app->cssTheme();
std::string newTheme = oldTheme == "default" ? "polished" : "default";
app->setCssTheme(newTheme); // Toggle the theme between 'default' and 'polished'
_btnToggleTheme->setText("Change to " + oldTheme);
// Make the client reload the css
app->doJavaScript(app->javaScriptClass() + ".updateStyles()");
}
示例4: validateWidgetAndTellBrowser
/// Validates the widget and passes the message on to the browser
static Result validateWidgetAndTellBrowser(WFormWidget* widget) {
ServerSideValidator* validator = dynamic_cast<ServerSideValidator*>(widget->validator());
if (validator != 0) {
WString value = getValue(widget);
Result result = validator->validate(value);
tellClient(widget, value, result);
return result;
} else {
Wt::WApplication* app = Wt::WApplication::instance();
app->doJavaScript( app->javaScriptClass() + ".WT.validate(" + widget->jsRef() + ");" );
return widget->validate();
}
}