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
Then, I bind a .click() to that $('#ext') that runs the jq.post() script, at the end of the script like thisCode:jq("div:first").after("<div id='ext'>Email this</div>");
But it does not even trigger the alert()! I went to "Inspect Element" and there were no event listeners.Code:jq('#ext').click(function(){ emailthis(); alert("posting... worksssss"); });
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.


LinkBack URL
About LinkBacks



Reply With Quote
