Project

General

Profile

setStyleClass doesn't clear the current style

Added by yvan vander sanden almost 8 years ago

Hey,

I'm unable to replace a style class on a button. Using this code:

Wt::WTemplate * t = new Wt::WTemplate(Wt::WString::tr("dialogtemplate.createproject"));
Wt::WPushButton * confirm = new Wt::WPushButton("Confirm");
confirm->setStyleClass("btn-primary");
t->bindWidget("button", confirm);

I would expect the css class to contain only btn-primary, but instead I get:

<button id="oa84w7w" type="button" class="btn-primary btn btn-default with-label">Confirm</button>

It looks like Wt adds some other classes to my button, which override the ones I added. I even tried adding:

confirm->removeStyleClass("btn-default", true);

but that doesn't do anything. Any ideas?

I am using the windows binary release: Wt-3.3.5-msvs2013-Windows-x64-SDK.exe from github.


Replies (1)

RE: setStyleClass doesn't clear the current style - Added by yvan vander sanden almost 8 years ago

Ok, I still don't know why btn-default doesn't get cleared, but I fixed the issue by moving the btn-default declaration in front of btn-primary in the css file.

    (1-1/1)