I am in the process of creating a custom 'textfield' plugin where the user will be presented with a select box of options for the value of the textfield's name attribute as opposed to the usual textfield requiring the user to type in the value directly.
The custom plugin was modeled after the pre-installed textfield plugin and not many changes were needed to produce the intended results. The plugin is nearly complete except that I have not determined how to dynamically alter the options of the select box.
A text diff showing the relevant changes between the textfield plugin and my custom textfield plugin is shown below:
The reason for the need to dynamically alter the options of the select box is to prevent the user from creating more than one textfield having the same value for the 'name' attribute. Naturally, the select box list should shorten as more textfields are created.
I have determined that the return_s_options() function is triggered only once during the opening of the first dialog box and thus is not updated during subsequent dialog box openings.
My only thought/workaround would be to directly modify the object holding the items of the select box.
Does anyone know how to access this object or perhaps have a better solution?
-see attached print screen
The custom plugin was modeled after the pre-installed textfield plugin and not many changes were needed to produce the intended results. The plugin is nearly complete except that I have not determined how to dynamically alter the options of the select box.
A text diff showing the relevant changes between the textfield plugin and my custom textfield plugin is shown below:
/plugins/forms/textfield.js id:'_cke_saved_name', type:'text', label:editor.lang.textfield.name, 'default':'', accessKey:'N',
/plugins/mycustomtextfield/textfield.js id:'_cke_saved_name', type:'select', /* make it a select element */ label:editor.lang.textfield.name, 'default':'0', accessKey:'N', style:'width:100%', items:return_s_options('UnusedFields',false) /* function returns pre-defined select items */
The reason for the need to dynamically alter the options of the select box is to prevent the user from creating more than one textfield having the same value for the 'name' attribute. Naturally, the select box list should shorten as more textfields are created.
I have determined that the return_s_options() function is triggered only once during the opening of the first dialog box and thus is not updated during subsequent dialog box openings.
My only thought/workaround would be to directly modify the object holding the items of the select box.
Does anyone know how to access this object or perhaps have a better solution?
-see attached print screen
Re: Dynamic Select Items - Help
Re: Dynamic Select Items - Help
Re: Dynamic Select Items - Help
I discovered this the other day after spending more hours into my ckeditor integration project.
However, the problem I now face is that the select element is not assigned a constant id value making it very difficult for me to locate and manipulate.
I found that during a single editor instance, the select element will be given an id value similar to xx_uiElement during the initial dialog definition. This value remains constant during the life of the editor instance. That is, the xx_uiElement id value will go unchanged regardless of the number of times the dialog is opened and closed.
However, once the editor is closed and destroyed, the same select element will be assigned a different id value (i.e yy_uiElement) when a new editor instance is created having identical settings and plugings.
This is a HUGE problem since the user may actually need to reopen a previously closed editor to add or correct the changes just made.
Would keeping all editor instances 'alive' be the solution for me?
I am not too keen about this option as the user may actually open several different editors during a single session.
Attachments:
Re: Dynamic Select Items - Help
Re: Dynamic Select Items - Help
Hey alfonsoml,
I really appreciate your help but can you provide me an example of using the .$ property of the uiElement?
Is that used inside my plugin definition and, if so, how?
What is the object of that property (uiElementObject.$) ??
Re: Dynamic Select Items - Help
Re: Dynamic Select Items - Help
Thank you for your help!
Although you did not provide the explicit solution you definitely pointed me in the right direction.
Here is how I managed to obtain a reference to the "real" select box.
Re: Dynamic Select Items - Help
I post my solution to change dynamically a combobox in function of other combobox. I hope this example helps to someone.
Re: Dynamic Select Items - Help
File: plugins/inserthtml/plugin.js
File: plugins/inserthtml/dialogs/inserthtml.php
Basically All I did was load a .php file rather then a .html and then populated the items list from the database.
I havent modified the function to put the code into the dialog box yet, only the code to populate the drop down list.