Как получить идентификатор тура в postRideCallback в Joyride

0

Я использую плагин joyride для экскурсий. Мне нужно получить идентификатор тура (id тега ol), по которому инициатор joyride был инициирован в функции postRideCallback. Эта функция имеет только index и current_tip качестве параметра, и я понятия не имею, как получить идентификатор в handlePostRideCall, я изучил библиотеку и ничего не работает.

HTML:

/* Each tip is set within this <ol>. */
/* This creates the order the tips are displayed */
<ol id="joyRideTipContent">
  /* data-id needs to be the same as the parent it will attach to */
  <li data-id="newHeader">Tip content...</li>

  /* This tip will be display as a modal */
  <li>Tip content...</li>

  /* using 'data-button' lets you have custom button text */
  <li data-class="parent-element-class" data-options="tipLocation:top;tipAnimation:fade" data-button="Second Button">Content...</li>

  /* you can put a class for custom styling */
  <li data-id="parentElementID" class="custom-class">Content...</li>
</ol>

JS:

<script>
    $(window).load(function() {
        $('#joyRideTipContent').joyride({
            autoStart : true,
            postStepCallback : handlePostRideCall,
            modal:true,
            expose: true
        });
    });

    function handlePostRideCall(index, tip){
        // get ol ID here
    }
</script>
Теги:
zurb-joyride

1 ответ

1
Лучший ответ

Создать переменную

var joyride_parent_id;

Затем в tip_template: function (opts) { function вы можете получить идентификатор родительского ol и сохранить его в переменной, которую мы определили выше

 joyride_parent_id = $(opts.li).parent().attr('id');

Теперь нам нужно передать его функции обратного вызова, вызываемой при закрытии события

end : function () {
        .......
        if (settings.$li) {
          settings.postStepCallback(settings.$li.index(), settings.$current_tip);
          settings.postRideCallback(settings.$li.index(), settings.$current_tip, joyride_parent_id);
        }
        $('.joyride-modal-bg').hide();
      },

Ещё вопросы

Сообщество Overcoder
Наверх
Меню