Picture of Jason Chui
How to implement Action Listener
by Jason Chui - Monday, 28 January 2019, 2:56 AM
 

I have created a textConfirmation in the plugin, properties.schema. How can i implement an action listener on this textbox for e.g whenever the user key in an input into the textbox or when the user press enter button ?

I have tried

function(ComponentView, Adapt) {
var TextConfirmation = ComponentView.extend({
events: {
'click [type="checkbox"]': 'onConfirmation',
'keyup .component-item input':'onKeyPress'
//This is new Code
}
 
onKeyPress: function(event) {
if (event.which !== 13) return;
console.log("asd")
}
 
but it is not working

 



Picture of Matt Leathes
Re: How to implement Action Listener
by Matt Leathes - Monday, 28 January 2019, 10:22 AM
 

The short answer is: you can't.

Longer answer: you're trying to mix together two completely separate pieces of functionality.

The .schema files allow you to define configurable properties for your plugin in the adapt authoring tool.

The JavaScript code you posted above and in this post controls the behaviour & functionality of your plugin when it is published from the authoring tool as an elearning course and run by a learner.

You cannot use this JavaScript code to affect what happens in the authoring tool. The authoring tool doesn't have any sort of plugin architecture to allow you to change its behaviour.

If you could explain a bit more about what it is you are trying to do it would be easier for people to guide you...