2broken2
Posts: 18
Joined: Tue Nov 23, 2010 7:11 pm

Javascript in Caption Fails( Please, help!

Hello!

What i'm trying to do is to add a javascript after caption which turns on http://vkontakte.ru/developers.php?o=-1&p=Comments comments system for every single image when when we click on it.

Having spent many hours on this forum i came to a conclusion that i should use hs.Expander.prototype.onAfterGetCaption script in my header.php to have a desired result (in Wordpress)

these were my steps:

1) added required scripts before </head>
2) added another script in header:

<script type="text/javascript">
hs.Expander.prototype.onAfterGetCaption = function (sender) {
if (sender.caption) {
sender.caption.innerHTML += '<h3>Leave a Comment:</h3>' +
'<div id="vk_comments"></div>' +
VK.Widgets.Comments("vk_comments", {limit: 20, width: "496"});
}
}
</script>


3) didn't get the result (

I had some luck after turning on a ready pre-made vkcomments plugin - http://wordpress.org/extend/plugins/vkcomments/ for adding comments to posts with all steps above. But unfortunately it doesn't work correctly


Please! maybe something wrong in hs.Expander.prototype.onAfterGetCaption. Or maybe there are any other variants??
User avatar
RoadRash
Posts: 8249
Joined: Tue Jul 15, 2008 6:43 pm
Location: Fredrikstad, Norway
Contact: Website

Re: Javascript in Caption Fails( Please, help!

Hi,

Are your aware that hs.Expander.prototype.onAfterGetCaption requires highslide-full.js?
If it doesnÔÇÖt work with highslide-full.js we need to see your live page.
Hilde
Highslide Support Team

Overview of my Highslide sample pages: RoadRash.no
2broken2
Posts: 18
Joined: Tue Nov 23, 2010 7:11 pm

Re: Javascript in Caption Fails( Please, help!

RoadRash wrote:Hi,

Are your aware that hs.Expander.prototype.onAfterGetCaption requires highslide-full.js?
If it doesnÔÇÖt work with highslide-full.js we need to see your live page.
Sorry, but i don't get how hs.Expander.prototype.onAfterGetCaption is connected with highslide-full.js and how should it work.. all i know is that i have highslide-full.js in my folder.
i managed to add some text after caption with the help of hs.Expander.prototype.onAfterGetCaption, but there was no luck with the "comments" script i need there.
if u look at my gallery - http://ogoblog.net/posts/378 u'll see that in the bottom of the post i have this "comments" script working.

Image

SO, i have vkcomments plugin activated and this is the script i added to header:

<script type="text/javascript">
hs.Expander.prototype.onAfterGetCaption = function (sender) {
if (sender.caption) {
sender.caption.innerHTML += '<h3>Leave a Comment:</h3>' +
'<div id="vk_comments"></div>' +
VK.Widgets.Comments("vk_comments", {limit: 10, width: "496"});
}
}
</script>


this script brings this when u click on a photo:
Image

The script seems to be working but in a wrong place! The script creates a single comments form in the dimmed background area every time u click on a thumbnail.. every time a new one form!!!
And my task is to put the comments form instead of "undefined" which u can see below the caption under each single photo!

2) i tried another way without using vkcomments plugin. i added the script manually as described http://vkontakte.ru/developers.php?o=-1&p=Comments but what i didn't get the desired result either ((

Please, Help! this integration could be really useful for many people!
Thanks
User avatar
RoadRash
Posts: 8249
Joined: Tue Jul 15, 2008 6:43 pm
Location: Fredrikstad, Norway
Contact: Website

Re: Javascript in Caption Fails( Please, help!

This is what you need to have in the onAfterGetCaption event:

Code: Select all

hs.Expander.prototype.onAfterGetCaption = function(sender) {
    if (sender.caption) {
        sender.caption.innerHTML += '<h3>Leave a Comment:</h3><div id="vk_comments_'+ this.key +'" style="height: 130px;"></div>'
        VK.Widgets.Comments("vk_comments_"+ this.key, {
            limit: 10,
            width: "496"
        });
    }
};
Hilde
Highslide Support Team

Overview of my Highslide sample pages: RoadRash.no
2broken2
Posts: 18
Joined: Tue Nov 23, 2010 7:11 pm

Re: Javascript in Caption Fails( Please, help!

The comment form was added in caption area! It worked but still... it is linked to a page but not to a single image. a comment sticks to all images :(
I guess that's because the comments plugin is linked to the url.
is it somehow possible to link to an image???
User avatar
RoadRash
Posts: 8249
Joined: Tue Jul 15, 2008 6:43 pm
Location: Fredrikstad, Norway
Contact: Website

Re: Javascript in Caption Fails( Please, help!

ThatÔÇÖs a case for the comment plugin ÔÇô not for Highslide.
Hilde
Highslide Support Team

Overview of my Highslide sample pages: RoadRash.no

Return to “Highslide JS Usage”