Skip to content

How to run the js code in the phtml #157

@reply2future

Description

@reply2future

Goal

Configuration UI

image

Issue

I would like to add input event to the input element, but it didn't work and didn't log any thing. The code in the file configure.phtml:

<script defer="defer" async="async">
	'use strict'
	console.log('load the openai extension configure page');

	(function() {
		console.log('add output event');
		function _addOutputEvent(element) {
			console.log('element:', element);
			if (element === null) return;

			element.addEventListener('input', function() {
				this.nextElementSibling.value = this.value;
				console.log(this.id, this.value);
			});
		}
		_addOutputEvent(document.getElementById('max_tokens'));
		_addOutputEvent(document.getElementById('temperature'));
	})();
</script>

The output of console:
image

Appreciate for any help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions