0
我已經使用GWT中的常規html構建了一個菜單,如下所示。 GWT將動態菜單項添加到自定義生成的菜單中
\t <g:HTMLPanel>
\t \t <div id="navigation">
\t \t <div id="menuLeft" class="menu">
\t \t \t \t <ul>
\t \t \t \t \t <li>
\t \t \t \t \t \t <g:Anchor ui:field="homeLink" styleName="active"><i class="fa fa-home"></i> Home</g:Anchor>
\t \t \t \t \t </li>
\t \t \t \t \t
\t \t \t \t \t <li class="active">
\t \t \t \t \t \t <a href="#"><i class="fa fa-suitcase"></i> Businesses</a>
\t \t \t \t \t \t <ul ui:field="businessesMenu">
\t \t \t \t \t \t \t <li>
\t \t \t \t \t \t \t \t <g:Anchor ui:field="enrollBusiness">Enroll Business </g:Anchor>
\t \t \t \t \t \t \t </li>
</ul>
</li>
</ul>
.....
,因爲它渲染提供的非常漂亮,使用CSS。一切都很好,直到這一點,現在的要求;爲此,我必須添加基於某些業務邏輯的動態菜單項,這意味着我必須在現有菜單中添加更多的菜單項。
我能夠建立/添加動態項目,但無法添加事件處理程序。
任何幫助表示讚賞。
嗨我實施了建議的修復程序,但它並沒有爲我工作我做了完全相同的解決方案。 LIElement menuItem = Document.get()。createLIElement(); Anchor itemLink = new Anchor(); itemLink.setText(「Business 1」); itemLink.addClickHandler(新函數clickhandler(){ 公共無效的onClick(ClickEvent事件){ \t \t \t} }); \t \t Element linkElement = itemLink.getElement(); menuItem.appendChild(linkElement); businessMenu.appendChild(menuItem); (linkElement,Event.getTypeInt(ClickEvent.getType()。getName())| DOM.getEventsSunk(linkElement)); – Grandhe 2014-09-26 15:12:04