sizzlemctwizzle / GM_config

A lightweight, reusable, cross-browser graphical settings framework for inclusion in user scripts.

Home Page:https://github.com/sizzlemctwizzle/GM_config/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dynamically creating fields

chlorophylls opened this issue · comments

I've scoured the wiki and can't seem to find documentation or an example on how to programmatically create a new field.

For instance, clicking a button to create a new text field, with certain default text, in a specific section such that it shows up underneath the other already-created fields in the config panel. Have I missed something?

I actually ran into this use case myself and had to use a hack to get it working. This functionality will be included.

How I'm going to implement this:
GM_config.init will append new fields to the frame if open. Add an onload event to fields so you can move these new fields to where you want them in the frame. Pass onInit callback to init along with the new fields to access them in the frame.

Does not create new sections. Appends all new fields to the last section in the open frame. Use close and then open to do a full refresh of the frame.

@sizzlemctwizzle can we get an example of what you're talking about?