I have an element (it is small, a dropdown for a color picker) that, for some reason, disappears when the enter key is pressed in any textbox on the page.
This doesnt happen on my non-WP site and I also notice that it only happens, specifically, when the enter key is pressed and the contents of a textbox change–if the value of the textbox is not modified and you hit enter, my element does not disappear.
Visually, if you look at textboxes on the WP admin page, when you click in them and give the focus, there is a blue highlight that surrounds the box. When you change the value in the textbox and hit enter, the blue highight disappears. That is exactly when my element disappears. So there is a definite relationship there.
I have checked the console and it is not just hidden or moved, it disappears.
I dont even know where to begin to try and resolve this, is there any way to change the WP behavior to not show this blue hightlight. I figure if I start there, maybe it will lead me to something helpful.
]]>But Im not sure what you mean. Ill try to give more info and hopefully I will answer your question.
Im on the page: https://www.mysite.com/wordpress/wp-admin/widgets.php
I have created a plugin/widget and as part of it, there are options the user can select–so I think, yes, it is controlling a specific plugin–the one I have created.
As part of creating the widget options there is the “function form” In this function, I build the various textboxes and dropdowns. It is here where i also have a dropdown for a colorpicker and that is what is disappearing.
I have made sure the class names are unique.
The best I can tell is that when the blue highlght disappears (like the one around this textarea I am typing in now)it takes my dropdown with it.
]]>The elements that are disappearing are loaded via js when the page is loaded. So it seems this is wiping them out.
Is there a way to load elements after the form has been loaded, not when the page loads? This way, the elements would be loaded again on each form load.
I have tried $(document).ready and that does not seem to do it. I assume if I put the form name instead of document it may work. But WP creates the form and it has no name or id (which seems strange)
]]>I simply took the js script that sets up these elements and, instead of using “enqueue_scipts” within “admin_enqueue_scripts”, I just put my script in the function form section with:
<script src="jsfile.js"></script>
With a few changes to that script it works fine.
But is it ok to load a script like this in the admin page?
]]>