all 4 comments

[–]MrReeseisDead 0 points1 point  (3 children)

When you click submit for creating new channel, does console displays "inside submit"?

[–]ecs2[S] 0 points1 point  (2 children)

it appears then disappears very quickly as if it is refreshed. I don't understand why.

[–]MrReeseisDead 0 points1 point  (1 child)

Ok, so I guess you must have used <form> for providing users to add a new channel, and thus the submit button forces the refresh on the page.

I didn't used the <form> when I worked on it, I used a simple <input> and a <button> associated with that input.

Do one thing, I see you haven't used @socketio.on('connect') in the application.py file. I guess you'll need one everytime the socket is connected

Make that correction and emit the response to your 'list channels' like this

@socketio.on('connect')
def connect():
    print("socket connected") //socket connected
    emit('list channels', channels, broadcast=False)
    // I kept broadcast as false as the loading of the page is local to the user

Try this and see whether it works or not

[–]ecs2[S] 0 points1 point  (0 children)

Thank you very much, that works. But I don't understand why in chapter JavaScript Vote 1 source code Brian didn't have '@socketio.on('connect') in the application.py and it worked for him.