add "wrap" ui functions #301

pyjsorg opened this Issue Apr 27, 2012 · 2 comments


None yet

2 participants

pyjsorg commented Apr 27, 2012

this is a TODO reminder, to look at GWT widget "wrap" functions and duplicate them in pyjamas.ui. it's not necessary to add 25 identical "wrap" functions, one will do, at UIObject, using the pyjamas.ui.Factory class.

Original issue: (June 11, 2010 13:57:53)

gpitel commented Jan 3, 2014

My Google search led me here. I would love to see this feature added :)

gpitel commented Jan 3, 2014

I added a work around for lack of wrap. Code below should also be helpful in implementing the wrap function.

I was trying to update all the hyperlinks from HTML returned by a server with new click listeners. The GWT recommend way to accomplish this is with the wrap function (i.e, Hyperlink.wrap(elemement) which is not implemented yet for pyjs. To work around the issue I create I swap the DOM elements with a Widget. Then I assign the Widget's Click listener.

html4 = HTMLPanel(serverXml)
    for idx, elem in enumerate(html4.findTags('a')):
        parent = DOM.getParent(elem)
        href = DOM.getAttribute(elem, 'href')
        text = DOM.getInnerHTML(elem)
        link =iHyperlink(text, href, Element = DOM.createSpan())
        link.setID('link' + str(idx))
        DOM.replaceChild(parent, link.getElement(), elem)
        DOM.sinkEvents(link.getElement(), Event.ONCLICK)
        DOM.setEventListener(link.getElement(), link)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment