jQuery Function not working. . .
Permalink
Hello all,
I've got a simple thing, but it's simply not working and it's killing me!
I'm using the InCurl Add-on to retrieve a table from another site. That's working great.
I have a page type specified for the pages InCurl is used on, and in that page type, I have the following jQuery:
All I want to do is get the absolute links that InCurl is writing for me and add a class of "Alert" to them. Ultimately, this will be setup to cause a modal window to fire when the external links are clicked to inform the user that they're about to be redirected to the main website I'm pulling the data from w/ InCurl.
However, I gotta get those links written first w/ a class of "Alert" on them.
Any suggestions on why this simple little script is not working?
Thanks in advance for your advice.
Absolute
I've got a simple thing, but it's simply not working and it's killing me!
I'm using the InCurl Add-on to retrieve a table from another site. That's working great.
I have a page type specified for the pages InCurl is used on, and in that page type, I have the following jQuery:
<script type="text/javascript"> // jQuery Alert: inform user they're going to another site to complete transaction $(document).ready(function() { $("a[href*='http://']:not([href*='"+window.location.hostname+"'])") .addClass("Alert").attr("target","_blank"); }); </script>
All I want to do is get the absolute links that InCurl is writing for me and add a class of "Alert" to them. Ultimately, this will be setup to cause a modal window to fire when the external links are clicked to inform the user that they're about to be redirected to the main website I'm pulling the data from w/ InCurl.
However, I gotta get those links written first w/ a class of "Alert" on them.
Any suggestions on why this simple little script is not working?
Thanks in advance for your advice.
Absolute
Hey Steve,
There is not such thing as a stupid question, just stupid answers.
I believe it could be, but my experience w/ OOP based PHP is null. And since I bought the InCurl package, I'm hesitant to mess w/ it, though I could make a copy and mess w/ it.
I just figured jQuery would be easiest. The table I'm scraping from the remote server is ancient and includes HTML presentation tags, such as FONT-COLOR, etc, so that's something I'll be looking into removing as well.
I just figured jQuery would get me there faster, but if you've got some ideas in PHP, I'm all ears.
Thanks!
There is not such thing as a stupid question, just stupid answers.
I believe it could be, but my experience w/ OOP based PHP is null. And since I bought the InCurl package, I'm hesitant to mess w/ it, though I could make a copy and mess w/ it.
I just figured jQuery would be easiest. The table I'm scraping from the remote server is ancient and includes HTML presentation tags, such as FONT-COLOR, etc, so that's something I'll be looking into removing as well.
I just figured jQuery would get me there faster, but if you've got some ideas in PHP, I'm all ears.
Thanks!
Well, I'm certainly a big fan of jQuery, but in this case it seems a server-side solution is more appropriate - especially given that you want to clean up some of the mark-up.
It might not be as bad as you think. Perhaps overriding the default view template with one having a bit of custom PHP logic might be all it takes. Just copy the block's view.php file into a mirror directory in your root, give it a new name, and hack away. Again though, I have no experience with the InCurl block, so it might or might not be that simple.
-Steve
It might not be as bad as you think. Perhaps overriding the default view template with one having a bit of custom PHP logic might be all it takes. Just copy the block's view.php file into a mirror directory in your root, give it a new name, and hack away. Again though, I have no experience with the InCurl block, so it might or might not be that simple.
-Steve
Hey Steve,
Just wanted to drop you a quick line and say thanks for encouraging me to try to get the job done w/ PHP.
Turned out to be a cinch, thanks to xPath and the DOM!
Most of what I needed to grab was already there and functioning, I just needed to modify it a bit.
I was able to use strip_tags() in PHP to remove or edit what I needed to.
Then was able to use xPath removeAttribute and setAttribute to handle the rest.
All is working great now. Thanks for your advice.
Only thing I wasn't able to do was put the table header info in a <thead> element. I really wanted that so I could add a floating table header to it, but alas, that one wasn't meant to be. Overall though, I've done what I needed, the <thead> was just a little more polish.
Thanks again!
Just wanted to drop you a quick line and say thanks for encouraging me to try to get the job done w/ PHP.
Turned out to be a cinch, thanks to xPath and the DOM!
Most of what I needed to grab was already there and functioning, I just needed to modify it a bit.
I was able to use strip_tags() in PHP to remove or edit what I needed to.
Then was able to use xPath removeAttribute and setAttribute to handle the rest.
All is working great now. Thanks for your advice.
Only thing I wasn't able to do was put the table header info in a <thead> element. I really wanted that so I could add a floating table header to it, but alas, that one wasn't meant to be. Overall though, I've done what I needed, the <thead> was just a little more polish.
Thanks again!
Nice job! Glad you worked it out.
Regards,
-Steve
Regards,
-Steve
This is probably a stupid question, and I might not be understanding the issue entirely, but is there any reason the alert class can't be added server-side? I know nothing about InCurl, but I'm assuming it's one server fetching data from another, so why can't the appropriate mark-up (in this case, a class attribute) be added before it's sent to the browser?
-Steve