Hey Koen,
We (with smart) found the problem in WWebWidget::updateDom() (see the
patch in the attachment).
I also documented the mission of the force argument of addStyleClass() and
removeStyleClass().
Regards,
Dmitriy
2010/6/29 Dmitriy Igrishin <[email protected]>
> Hey Koen,
>
> We (with smart) found the problem in WWebWidget::updateDom() (see the
> patch in the attachment).
> I also documented the mission of the force argument of addStyleClass() and
> removeStyleClass().
>
> Regards,
> Dmitriy
>
> 2010/6/29 Koen Deforche <[email protected]>
>
> Hey Dmitriy,
>>
>> 2010/6/21 Dmitriy Igrishin <[email protected]>:
>> > Hey all,
>> >
>> > addStyleClass() and removeStyleClass() of WWebWidget when called with
>> force
>> > = true
>> > argument does not update the corresponding property of the DOM element.
>> > The flag BIT_STYLECLASS_CHANGED should be always set when we
>> > set styleClass_ of lookImpl_ regardless force or not force.
>> > The applied patch solves this problem.
>>
>> I do not see the problem with the existing code though. When
>> force=true, Wt will use a JavaScript call to add or remove the
>> styleclass from the DOM element, see lines 1284 e.a. This is done
>> whenever transientImpl_ contains one or more style classes to be added
>> or removed. In that case, there is no need (and it is even wrong!) to
>> also set the entire styleClass on the DOM element. The underlying
>> assumption is that JavaScript manipulations of the style class may
>> have caused the widget style class and DOM element style classes to go
>> out of sync -- and this should not be affected by adding or removing
>> style classes.
>>
>> Do you have a test case that demonstrates wrong behaviour ?
>>
>> Regards,
>> koen
>>
>>
>> ------------------------------------------------------------------------------
>> This SF.net email is sponsored by Sprint
>> What will you do first with EVO, the first 4G phone?
>> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
>> _______________________________________________
>> witty-interest mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/witty-interest
>>
>
>
diff --git a/src/Wt/WWebWidget.C b/src/Wt/WWebWidget.C
index cc4c53d..161e5c0 100644
--- a/src/Wt/WWebWidget.C
+++ b/src/Wt/WWebWidget.C
@@ -1268,12 +1268,12 @@ void WWebWidget::updateDom(DomElement& element, bool all)
if (transientImpl_) {
for (unsigned i = 0; i < transientImpl_->addedStyleClasses_.size(); ++i)
- element.callJavaScript("$('" + id() + "').addClass('"
+ element.callJavaScript("$('#" + id() + "').addClass('"
+ transientImpl_->addedStyleClasses_[i].toUTF8()
+"');");
for (unsigned i = 0; i < transientImpl_->removedStyleClasses_.size(); ++i)
- element.callJavaScript("$('" + id() + "').removeClass('"
+ element.callJavaScript("$('#" + id() + "').removeClass('"
+ transientImpl_->removedStyleClasses_[i].toUTF8()
+"');");
}
diff --git a/src/Wt/WWidget b/src/Wt/WWidget
index 9173ff8..baecd25 100644
--- a/src/Wt/WWidget
+++ b/src/Wt/WWidget
@@ -536,6 +536,9 @@ public:
virtual WT_USTRING styleClass() const = 0;
/*! \brief Adds a CSS style class.
+ *
+ * When force = true, Wt will use a JavaScript call to add the style
+ * class to the DOM element.
*/
virtual void addStyleClass(const WT_USTRING& styleClass,
bool force = false) = 0;
@@ -543,6 +546,9 @@ public:
void addStyleClass(const char *styleClass, bool force = false);
/*! \brief Removes a CSS style class.
+ *
+ * When force = true, Wt will use a JavaScript call to remove the style
+ * class from the DOM element.
*/
virtual void removeStyleClass(const WT_USTRING& styleClass,
bool force = false) = 0;
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest