adding an element after another

31 views
Skip to first unread message

Lukasz Grabowski

unread,
Jul 29, 2017, 1:59:41 PM7/29/17
to brython
Hi, Since it's my first post - hello everyone and big thanks to the developers!

I coudn't find in the demo page (https://www.brython.info/demo.html?lang=en)
how to brythonically insert an element after or before another element - could someone explain how to do it?

I found some docs by googling:
http://brython.readthedocs.io/en/master/site/doc/en/pydom/after/

but both demo frames say "permission denied"

Best,
Lukasz

Pierre Quentel

unread,
Jul 31, 2017, 4:37:02 AM7/31/17
to brython


Le samedi 29 juillet 2017 19:59:41 UTC+2, Lukasz Grabowski a écrit :
Hi, Since it's my first post - hello everyone and big thanks to the developers!
 
Welcome to the group Lukasz !

In the latest commit I added examples of "insert before" and "insert after" in the demo page. As you will see it uses standard DOM methods ; we try to limit the Brython-specific syntax or methods to what seems more convenient than the DOM API.

You will also note that these examples use Python 3.6 f-strings which I introduced recently.

The documentation you mention is relative to pydom, a module that proposes a set of specific methods and attributes. It's not part of the Brython standard distribution and I'm not sure if it's still maintained.

Best,
Pierre

Łukasz Grabowski

unread,
Aug 1, 2017, 3:44:10 PM8/1/17
to bry...@googlegroups.com
> In the latest commit I added examples of "insert before" and "insert
> after" in the demo page. As you will see it uses standard DOM
> methods ; we try to limit the Brython-specific syntax or methods to
> what seems more convenient than the DOM API.

Are these examples for a specific version of brython? I keep getting an
error "AttributeError: 'DOMNode' object has no attribute 'insertAfter'"


Lukasz

Łukasz Grabowski

unread,
Aug 1, 2017, 3:54:52 PM8/1/17
to bry...@googlegroups.com

> > In the latest commit I added examples of "insert before" and "insert
> > after" in the demo page.
> Are these examples for a specific version of brython? I keep getting
> an error "AttributeError: 'DOMNode' object has no attribute
> 'insertAfter'"

when I use insertBefore it works. Is this a bug or should I keep
looking for a stupid typo in my code?


L

Pierre Quentel

unread,
Aug 1, 2017, 4:25:17 PM8/1/17
to brython
There is no "insertAfter" method for DOM Nodes. If you take a look at the new version of the demo, you will see that the code to insert an element after another is not

parent.insertAfter(new_element, element)

but

parent.insertBefore(new_element, element.nextSibling)
 

Łukasz Grabowski

unread,
Aug 1, 2017, 4:36:01 PM8/1/17
to bry...@googlegroups.com
> > There is no "insertAfter" method for DOM Nodes. If you take a look
> > at the

Thanks, it's all clear now (may I use this opportunity to file a
feature request? :-))

L

Kiko

unread,
Aug 2, 2017, 7:39:49 AM8/2/17
to bry...@googlegroups.com
Welcome Lukasz,

The issue tracker or this mail list are both good places to ask for enhancements.

Please, fill a new issue (https://github.com/brython-dev/brython/issues) using [ENH] in the title or open a new thread in the mail list in order to better search the conversations.

Thanks.
 

L

--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+unsubscribe@googlegroups.com.
To post to this group, send email to bry...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/20170801213554.5aea6f6d%40brutus.lancaster.ac.uk.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages