Actions
Bug #4512
closedJQuery event handlers stop working after widget reparenting
Start date:
10/15/2015
Due date:
% Done:
0%
Estimated time:
Description
Here's a minimal example:
void reparent(WText *t, WContainerWidget *oldP, WContainerWidget *newP);
void click_slot();
Wt::WApplication* createApplication(const Wt::WEnvironment& env)
{
WApplication *app = new WApplication(env);
WContainerWidget *c = new WContainerWidget(app->root());
WPushButton *b = new WPushButton("Reparent", c);
WText *t = new WText(c);
t->setText(WString("My id is: {1}").arg(t->jsRef()));
t->clicked().connect(boost::bind(&click_slot));
t->doJavaScript("$(" + t->jsRef() + ").click(function() { console.log('click'); } )");
WContainerWidget *c2 = new WContainerWidget(app->root());
b->clicked().connect(boost::bind(&reparent, t, c, c2));
return app;
}
void reparent(WText *t, WContainerWidget *oldP, WContainerWidget *newP)
{
oldP->removeWidget(t);
newP->addWidget(t);
WString oldString = t->text();
oldString += WString(". My new id is: {1}").arg(t->jsRef());
t->setText(oldString);
}
void click_slot()
{
std::cout << "CLICK!" << std::endl;
}
I create a WText
widget and then attach a C event hadler to the clicked
signal and also attach a JQuery handler for js click
signal. Both handlers work fine. I can see debug output both in app console and browser console.
But when I reparent the widget, JQuery handler is not called anymore.
Updated by Koen Deforche over 9 years ago
- Status changed from New to Resolved
- Assignee set to Koen Deforche
- Target version changed from 3.3.1 to 3.3.5
Actions