Issue #2400✓ SolvedOpened November 12, 2019by ned-kelly4 reactions

Is it possible to 'toggle' a button added within Panel from function outside of GJS?

Quick answerby pouyamiralayi2

Hi @ned-kelly try this: cheers!

Read full answer below ↓

Question

Hi Guys, Firstly awesome project, have really enjoyed extending GJS to work with our use case - and am excited for what's in store looking at some of the issues/features in-progress... So, I'm using GJS to with custom buttons added into the Panel via addButton (like so): Now all works as expected when you toggle/untoggle the button - however I want to run the toggleCropMarkers() function which is called when the button is toggled, outside of the editor - (in this case I'm calling the function when the document is loaded) - and I would like to manually set the state of the button to 'toggled'....

Answers (2)

👍 Most helpfulpouyamiralayiNovember 12, 2019

Hi @ned-kelly try this:

 const cropBtn = editor.Panels.getButton('options', 'cropmarks');
 cropBtn.set('active', 1)

cheers!

ned-kellyNovember 13, 2019

@pouyamiralayi, you're amazing - sorry for asking what's seemingly a simple question - couldn't find any previous GitHub issues or comments about this in the documentation!

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.