Run Javascript In SP Page Builder - Question | JoomShaper

Run Javascript In SP Page Builder

A

Alvaro

SP Page Builder 4 years ago

All the JS scripts that you use are not included in the addons but in the editor's main library. I am creating an addon that uses swiper.js, in the site.php code I am not including the getTemplate() function, so to see what to see the results you have to press the APPLY button (similar to the addon module) I think that this button is shown in all addons that do not use the getTemplate() function. I have included the scripts files, and from the public side of the site (not editor) it works fine, the problem is in the front-end editor.

The question: why don't external JS scripts (included in addons) run inside the editor? or what should I do to get them to run?

I have initialized swiper inside the script tag and also with the js() function, but neither works in the live editor

initialization code: var swiper = new Swiper(".mySwiper", {});

Thanks in advance

0
4 Answers
Rashida Rahman
Rashida Rahman
Accepted Answer
Support Agent 4 years ago #17995

Hi there!

Thanks for contacting us.

Are you trying to create a custom addon? And following this?

https://www.joomshaper.com/blog/how-to-create-a-custom-addon-for-sp-page-builder

Actually,

  1. Custom JS script is not supported by us, so it's on your hands only. Support Policy.

  2. In SPPB documentation > How To Tips > How to use Custom JavaScript

Here is the link: https://www.joomshaper.com/documentation/sp-page-builder/sp-page-builder-3/how-to-tips#documentation-heading-20

Best Regards

0
A
Alvaro
Accepted Answer
4 years ago #17998

Hi Rashida Exactly I am creating an addon (I have created several without javascript). I am not trying to insert custom javascript to use in some addon. What I am doing is integrating swiper.js into the code of an addon with the following functions inside site.php

public function render() {
   // here code for create html
}
public function stylesheets () {
   // here code for load css files
}
public function scripts() {
   // here code for load swiper.js
}
public function js() {
   // here code for initialize swiper
   $js = 'var swiper = new Swiper (".mySwiper", {});';
   return $js;
}

I'm NOT using the live editor function public function getTemplate()

This works fine in the public part, but not in the live editor and I don't understand why. I am using javascript not jQuery.

If you could give me a reason why it does not run in the editor, I would be eternally grateful.

0
Rashida Rahman
Rashida Rahman
Accepted Answer
Support Agent 4 years ago #19048

Hi Alvaro,

I would be so happy if I could help you with this.

But I cannot help you with javascript, or any type of customization.

And it is prohibited here too.

You may need to consult with a programmer in your city.

If you have any queries related to our product default features, I will try to answer them at my best.

Best Regards

0
A
Alvaro
Accepted Answer
4 years ago #19075

I will not argue about whether it is prohibited or not, it is your policies or maybe a way to avoid it, but I still respect your decisions. I am not asking you to help me with customization, my question was clear and I will repeat it. Why doesn't an external js script run inside the editor? you have it blocked?

I just want to know that, to find a solution or if it is blocked no longer waste time. And I am asking for a default feature of the editor.

Thanks.

0