mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-21 06:37:42 +01:00
added possibility to add JS functions directly to page
This commit is contained in:
parent
b1f895eed8
commit
7ad83b7d4d
@ -120,6 +120,13 @@ void PageRenderer::renderHead(const Renderable* pRenderable, const RenderContext
|
||||
//start inline javascript block
|
||||
ostr << "<script type=\"text/javascript\">";
|
||||
ostr << "var global={};"; //global var to store values!
|
||||
const std::vector<std::string>& fcts = pPage->dynamicFunctions();
|
||||
std::vector<std::string>::const_iterator itF = fcts.begin();
|
||||
for (; itF != fcts.end(); ++itF)
|
||||
{
|
||||
ostr << *itF << std::endl;
|
||||
}
|
||||
|
||||
ostr << "Ext.onReady(function() {";
|
||||
ostr << "var " << VAR_LOCALTMP << ";"; // tmp variable needed for table renderer
|
||||
ostr << "Ext.QuickTips.init();";
|
||||
|
@ -93,6 +93,14 @@ public:
|
||||
|
||||
void handleForm(const std::string& field, const std::string& value);
|
||||
/// Dummy implementation
|
||||
|
||||
void addDynamicFunction(const std::string& jsCode);
|
||||
/// Adds a JavaScript function to the page. Static functions should be written to a JS file
|
||||
/// and included via the ResourceManager, only dynamic fucntions (ie. functions that are generated
|
||||
/// during run-time) should be included here
|
||||
|
||||
const std::vector<std::string>& dynamicFunctions() const;
|
||||
/// Returns all dynamic functions
|
||||
|
||||
protected:
|
||||
Page(const std::string& name, const std::type_info& type);
|
||||
@ -107,6 +115,7 @@ protected:
|
||||
private:
|
||||
std::string _text;
|
||||
ResourceManager _rm;
|
||||
std::vector<std::string> _jsCode;
|
||||
};
|
||||
|
||||
|
||||
@ -131,6 +140,18 @@ inline void Page::handleForm(const std::string& , const std::string& )
|
||||
}
|
||||
|
||||
|
||||
inline void Page::addDynamicFunction(const std::string& jsCode)
|
||||
{
|
||||
_jsCode.push_back(jsCode);
|
||||
}
|
||||
|
||||
|
||||
inline const std::vector<std::string>& Page::dynamicFunctions() const
|
||||
{
|
||||
return _jsCode;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::WebWidgets
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user