Picture of Chris Gillison
Calling adapt.trigger from a link
by Chris Gillison - Wednesday, 18 September 2019, 9:56 AM
 

Hi all,

I'm using the adapt-nameInput extension. It's launched by calling Adapt.trigger("name-input:open"). Really I want to launch it from a link (a href) in the body text of a component (e.g. adapt-contrib-text).

Is this possible to call an adapt.trigger from an href (and if so how would I write it?), or do I need to modify the .js and .hbs of the component? (Not a great explanation but hopefully you see what I mean!)

I'm using Framework version 4.3.0 with version 0.0.1 of nameInput.

Many thanks, Chris

Picture of Matt Leathes
Re: Calling adapt.trigger from a link
by Matt Leathes - Wednesday, 18 September 2019, 10:44 AM
 

absolutely, like this:

<a href=\"#\" onclick="require('core/js/adapt').trigger('name-input:open');return false;\">Click me!!</a>

With double-quotes escaped on the assumption that you'll be adding this to the JSON ;-)

Picture of Chris Gillison
Re: Calling adapt.trigger from a link
by Chris Gillison - Wednesday, 18 September 2019, 10:51 AM
 

PERFECT! Many thanks Matt.

Picture of Matt Leathes
Re: Calling adapt.trigger from a link
by Matt Leathes - Wednesday, 18 September 2019, 11:33 AM
 

If you're interested, you can also do something similar in the console to allow you to have a bit of a poke around the workings of Adapt... so essentially run something like this: var Adapt = require('core/js/adapt'); and then you have access to the whole Adapt object which you can explore.