3
我正在使用GWT並通過GWT-Bootstrap庫實現引導程序。在GWT/Bootstrap中設置數據屬性
我似乎無法找到一個方法來添加數據 - 屬性我的元素?
我可以直接寫入HTML做到這一點:
HTMLPanel htmlPanel = new HTMLPanel("<button type=\"button\" class=\"btn\" data-custom=\"some-custom-data\">Hello World</button>");
menuControl.add(htmlPanel);
但是,這只是醜陋和破壞使用GWT(還不如寫一個普通的HTML代碼)的目的。
我想辦法做這樣的事情:
Button button = new Button();
button.setText("Hello World");
button.setStyleName("btn");
// Fine up to here, but now i want:
button.setAttr("data-custom", "some-custom-data");
謝謝!我仍然有很多要了解GWT! – newbieAsker