Jump to content

IPS.Pages blocks and jQuery

Recommended Posts


Basically I have problem with feed blocks created from pages. I want to implement jQuery script along with specific block, however there seems to be load order issue because in console I see "jQuery is not defined", so things simply do not work as should.

I tried to wrap entire script inside: document.addEventListener("DOMContentLoaded", function(event) { ... }); that makes jQuery not defined error gone but still things do not work. I noticed that IPS.Pages blocks do not properly load pseudo-code style elements such as :before or :after, they are simply ignored and not applied. Same story with "data-role"s, seems like not being considered.

Example block code

document.addEventListener("DOMContentLoaded", function(event) {
  ;( function($, _, undefined){
	"use strict";

	ips.controller.register('site.front.site.FAQ', {
		initialize: function () {
			this.on( 'click', '[data-role="question"]', this.clickQuestion );

		clickQuestion: function (e) {
			var thisQuestion = $( e.currentTarget );

			if( thisQuestion.hasClass('sFAQ__q--active') ){
			} else {
}(jQuery, _));

{{if !empty( $records ) }}
<div class="sFAQWrap">
  <ul class="sFAQ" data-controller="site.front.site.FAQ">
			<ul class="ipsList_reset">
                {{foreach $records as $record}}
						<li class="sFAQ__q" data-role="question">
							<h3 class="h3">$record->_title</h3>
                          		<a href="{$record->url()}" class="ipsButton ipsButton_light ipsButton_narrow ipsButton_verySmall ipsCopyToClipboard enabled" data-ipstooltip="true" data-ipsdialog style="top: 8px; right: 8px;" _title="Product FAQ"></a>
								<div data-role="answer" style="display: none">
									<p class="text text--smaller sFAQ__q_text">$record->content</p>
	<hr class="ipsHr">
	<p class="text">
		Please <a href="/contact">contact us</a> if you have any other questions - we'd be happy to help.

Has anyone experienced similar problem? any suggestions?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...