Picture of Robert Drew Jeffrey
Use a name/ id tags for linking to specific parts of adapt
by Robert Drew Jeffrey - Sunday, 28 September 2014, 9:52 AM
 

Hi all,

i want to link to a page in my adapt course and have it jump to a certain section of the page.

I tried using aname/id tags but the page just shows the loading circle continuously.

Is there a way to use these tags/the same functionality built into adapt?

Thankyou,

Rob

Picture of Daryl Hedley
Re: Use a name/ id tags for linking to specific parts of adapt
by Daryl Hedley - Monday, 29 September 2014, 7:14 AM
 

Hey Robert,

It's a good question. Adapt does allow you to navigate through the use of model '_id's. The method you need to look at is Adapt.navigateToElement:

https://github.com/adaptlearning/adapt_framework/wiki/Adapt-API#adaptnavigatetoelement

Please do note that this only navigates to elements within a page. However it has the ability to navigate from one block on one page to another block on another page. You'll need to build an extension to handle the clicks - but this shouldn't be too hard. Try hooking into the pageView:ready event for binding your click events. Maybe add a class to the <a> tag that's descriptive of your plugin:

<a class="element-jumper-link" data-link="c-23">Click here to view more information</a>

So setting up your plugin you'll have something along the lines of:

Adapt.on(pageView:ready, function(pageView) {

    // On pageView:ready add event listeners
    $('.element-jumper-link', pageView.$el).on('click', function() {


        // When clicked grab the data-link attr on the <a> tag
        var linkId = $(this).attr('data-link');

        // Get the navigation height as navigateToElement will need to offset this
        var navigationHeight = $('.navigation').height();

        // Navigate to element - this takes in a jQuery style selector
        Adapt.navigateToElement('.' + linkId, {offset: -navigationHeight});

    });

});

Hope this helps.

Daryl

Picture of Robert Drew Jeffrey
Re: Use a name/ id tags for linking to specific parts of adapt
by Robert Drew Jeffrey - Tuesday, 30 September 2014, 12:47 PM
 

Hi Daryl,

 

THanks for the detailed reply! I will give this a crack

:)