• I need help with an issue on the widget option admin page.

    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.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Widget Options is not a standard a WordPress admin page. Is this controlling a specific plugin or feature if your theme?

    Thread Starter chz516

    (@chz516)

    ok, youll have to excuse my lack of knowledge here. I a new to PHP but have been able to do what I needed by finding example and working through them.

    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.

    Thread Starter chz516

    (@chz516)

    Normally, I can save the page as HTML and take it offline. this way I can eliminate code and scripts until I find the one with the issue.
    But in this case, for some reason, the behavior doesnt happen when I run locally–which is strange because the page still links to the same js and css.

    Thread Starter chz516

    (@chz516)

    How can I get a look at exactly what happens when the enter key is pressed inside of a textbox?

    Thread Starter chz516

    (@chz516)

    Hmmmm. It appears that hitting the enter key while in a textbox submits the form.

    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)

    Thread Starter chz516

    (@chz516)

    Ok, problem solved. I am just hoping someone can confirm if my solution is acceptable or if it may cause other issues.

    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?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Element Disappears on the Widget Options Page’ is closed to new replies.