0

I am running discourse and I am trying to modify what happens when one clicks the logout link, I do not want to modify discourse stock javascript...

  1. There is an element elem1 that when clicked inserts another html menu with the logout link. So is it not present when $(document).ready.. is called. I need to modify what happens on elem2.click which is where the logout link is.

I want to do this...

$("#elem1").click(function() {
    console.log("step1")
    $("#elem2").click(function () {
        console.log("step2")
        ..do my custom logout 
    })
})

but I think jquery is not finding it because it was not there when it first loaded.

Joff
  • 11,247
  • 16
  • 60
  • 103

1 Answers1

1

Change to this

$("#elem2").on('click',function () {
        console.log("step2")
        ..do my custom logout 
    })

or if you're using older jQuery:

 $("#elem2").live('click',function () {
            console.log("step2")
            ..do my custom logout 
        })
Aleksandar Matic
  • 789
  • 1
  • 9
  • 21