Help with slideObject

garycwynne's Avatar

garycwynne

25 Nov, 2012 09:06 PM

Hi,

I have the following code:

var sliderInstance = $(".royalSlider").data('royalSlider');
sliderInstance.ev.on('rsAfterContentSet', function(e, slideObject) {
   // Test code
    console.log(slideObject.holder);
});

In this case, the rsSlide represented by sliderInstance contains a div that contains an empty <p> element and of course, the <img>. I'm new to jQuery and want to replace the empty <p> element with my globalCaption <div>. I have tried various select attempts in Firebug but have not been able to get hold of any children, let alone the <p>. Is there any chance you could give me a pointer as to how to do this?

Many thanks.

  1. Support Staff 1 Posted by Dmitry Semenov on 26 Nov, 2012 08:14 AM

    Dmitry Semenov's Avatar

    Hi,

    I don't really understand why you need this and why you can't edit directly slider markup, to replace p with div:

    slideObject.holder.find('p').replaceWith('<div>Test</div>');
    

    Dmitry

  2. 2 Posted by garycwynne on 26 Nov, 2012 10:28 AM

    garycwynne's Avatar

    The <p> is a place holder and yes, I could use a <div>. However, that
    wasn't really the issue; the issue was how to target and get a reference
    to either the <p> or the <div> so that I could add the content of the
    globalCaption to it.

    I kept trying to "select", rather than the "find" method you have used in
    your sample code. I'll get up to speed with jQuery soon so many thanks for
    your response and patience. I tried to find documentation on the
    slideObject object model but there didn't seem to be any.

    Regards.

  3. Support Staff 3 Posted by Dmitry Semenov on 26 Nov, 2012 04:40 PM

    Dmitry Semenov's Avatar

    slideObject.content holds generated slide markup
    slideObject.holder holds slide container which is empty until slide is loaded

    // will return you p tag from first slide
    jQuery('.royalSlider').data('royalSlider').slides[0].content.find('p')
    

    Dmitry

  4. 4 Posted by garycwynne on 26 Nov, 2012 04:56 PM

    garycwynne's Avatar

    Thank you Dmitry - your help is very much appreciated :)

  5. Dmitry Semenov closed this discussion on 26 Nov, 2012 05:12 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac