Results 1 to 2 of 2

This is a discussion on bind a click to an added element? within the Chrome Plugins section, part of the Google Chrome category: I made this script for Craigslist, for emailing yourself the post, with one click. What basically provides a link to ...


  1. #1
    mvmacd is offline Junior Member
    Join Date
    May 2010
    Posts
    5

    Question bind a click to an added element?

    I made this script for Craigslist, for emailing yourself the post, with one click. What basically provides a link to my remote php script that parses the HTTP referer, [to get the posing ID, and the craigslist site] and then prints a <form> and is onload=sumit()'ed, it's not that efficient. So now I've been learning about jQuery's $.post(), and I tried it, and it works a lot better [and quicker], and doesn't need a remote php script.

    [btw, I use 'jq' instead of '$' for jQuery because I ran into conflicts once]
    Soo anyway, in my content script I have
    Code:
    jq("div:first").after("<div id='ext'>Email this</div>");
    Then, I bind a .click() to that $('#ext') that runs the jq.post() script, at the end of the script like this
    Code:
    jq('#ext').click(function(){
    emailthis();
    alert("posting... worksssss");
    });
    But it does not even trigger the alert()! I went to "Inspect Element" and there were no event listeners.

    So I tried binding the click to "body" instead of "#ext", and if I click on the page, then it alert()s and runs the jq.post() script [which is in the emailthis() function].

    Can anybody tell me why it will work if I bind the function to the "body" it works, but if I bind it to my "#ext" that I created, it doesn't work? I would really appreciate it! Thanks for taking the time to read this,
    Matt

    Ps. I put alert( jq("#ext")); at the beginning of my script, and it gives an error [Uncaught TypeError: Property 'jq' of object [object DOMWindow] is not a function]
    So then I move that to right before I call the .click(), and it alerts
    [object Object], so that means it does exist before it tries to set a .click() on it.

  2. #2
    mvmacd is offline Junior Member
    Join Date
    May 2010
    Posts
    5

    Default

    bumpity bump.

    anyone?

Similar Threads

  1. change double click context menu to single click.
    By bmorency in forum Chrome Troubleshooting
    Replies: 0
    Last Post: 07-25-2010, 02:08 AM
  2. switch tab & activate element
    By intro.david in forum Chrome Tips & Tricks
    Replies: 0
    Last Post: 01-12-2010, 10:21 PM
  3. Element Hider
    By solcroft in forum Chrome Plugins
    Replies: 31
    Last Post: 12-05-2009, 10:59 AM
  4. Latest Dev element inspector failing?
    By Michael3185 in forum Chrome Troubleshooting
    Replies: 2
    Last Post: 10-28-2009, 10:41 PM
  5. Event when x element is loaded
    By noctourne in forum Plugins Development
    Replies: 6
    Last Post: 08-01-2009, 11:21 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •