Meaning if the submit will.

 
Rudin: The only explanation is that the selector isn’t finding the form so the code never runs

Nakonechny: Cork, when the application loads

Cisneroz: The form is loaded but hided

Shaban: Baako: where you bind the event handler

Prokop: The event only come into page when the user have got to the stage where the form needs to do something

Anerton: Right before it run console.log$’same selector’.length

Delehanty: And make sure the number is 0

Fawcett: Also if you use an id, make sure it isn’t in use somewhere else

Vandersteen: Cork, when the page load it is 0

Powells: When i navigate to where the form is it is 1

Vaca: Delegate the event handler to a static parent

Pilcher: I have to go now back in 2 hours

Fesenmyer: Also make sure you have the code in a ready wrapper $function {}

Megia: Hey, I’m using a WYSIWYG editor but it’s producing XSS. User enters: <svg onload=alert’xss’> that gets saved to the DB as-is, the editor runs this.$textarea.val which returns svg onload=alert’xss’ and hence XSS shows. Any tips on how to solve that?

Malinky: Try $textarea.text instead

Lagrasse: Malinky: this seems to be a simplified version of what it’s doing https://jsfiddle.net/jz3u8o1b/

Malinky: Https://jsfiddle.net/jz3u8o1b/1/

Malinky: Setting with text escapes the string so it will not execute

Grzesik: Cork, am back. what type of delegate do i need in this case?

Woskobojnik: Isnt delegate the same has the .on

Rance: Baako: no delegate isn’t the same as on

Faith: Baako: delegate is something you can do with on

Tremmel: But it depends on how you call it

Virag: Baako: https://learn.jquery.com/events/event-delegation/

Filgo: Cork, the example in the link

Masella: Isnt it the same has $’form’.on’submit’, functione{

Mussa: Or do i need to use http://api.jquery.com/delegate/

Cuneio: The first add an event listener on #list listning for events from a elements inside it

Holiman: Your one looks for form elements and binds events on it

Kunc: If the form in your case doesn’t exist nothing gets added

Workman: If the a element doesn’t exist doesn’t matter

Moskovitz: If it later gets added inside #list it will still be caught

Fertig: So what does this do $’form’.on’submit’, functione{

Gawel: So instead of me using the form in the selector

Himber: I should use maybe the main div wrapper cl***?

Ihm: If main is static and the form is dynamically created at a future point, sure

Ihm: Though, that probably wont work

Ihm: As by the time the submit bubbles out of the form, :s

Rakow: Ihm, the form is created in the form

Ihm: Sure, but read my other statements

Ihm: So usually the point of binding on submit is because you want to do something, maybe some validation, and potentially cancel the submit

Ihm: If it’s already bubbled out of the form, it’s too late to do that stuff

Klepfer: Ihm, when the form is generated the button always get generated

Ihm: Ok, don’t listen to me. try it and see how it goes

Scipione: Ihm, you are tell me the possible issue

Poarch: Am no possible solution

Ihm: What is the problem your trying to solve?

Ihm: Https://jsfiddle.net/dbtk4m7v/

Ihm: As I was saying, if you delegate bind on submitting the form, you have to be aware that you will not be able to cancel the event

Ihm: Meaning if the submit will cause a page transition, that transition will happen regardlessly