Web Connection
Attach .JS() to a ww.WebTextBox control
Gravatar is a globally recognized avatar based on your email address. Attach .JS() to a ww.WebTextBox control
  George
  All
  Aug 24, 2019 @ 07:48am

Hi,

I need to modify an older project that used the web controls and attaches the date/timepicker with a script to a wwTextBox control. This all works exactly as expected.

My nuance is that this stops working if my control is housed inside a wwWebPanel control. I need to do this so that I can "hide" the entire panel including the time entry text box using the code behind approach.

I am pretty certain that this

    <script type="text/javascript">
        $("#tb1").timeKeys();
        $("#tb0").timekeys();
        $("#dpstart")
                .dateKeys()
                .datepicker(
                    { showOn: 'button',
                        buttonImageOnly: true,
                        buttonImage: 'css/images/calendar.png',
                        showButtonPanel: true
                    });
    </script>

Is where my error is. tb1 will work, whereas tb0 will not. The controls are identical, but tb0 is inside a lookup panel.

So my question (i think) is really "how should I make the script "find" my control?

Gravatar is a globally recognized avatar based on your email address. re: Attach .JS() to a ww.WebTextBox control
  Rick Strahl
  George
  Aug 24, 2019 @ 11:43am

The control IDs inside of a panel change due to the nesting. Take a look at the actual control IDs generated in the HTML (or with Browser Tools/Inspect). The name will be something like ctrl00_tb1 instead of tb1. You need to use the proper name or you can use the $$() function instead which tries to find the control in the tree regardless of the prefix albeit at a slight perf hit.

$$ JavaScript Function

$$("tb1").timeKeys();

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Attach .JS() to a ww.WebTextBox control
  George
  Rick Strahl
  Aug 24, 2019 @ 01:42pm

Thanks Rick,

That was extremely helpful, much appreciate the quick response.

George ...

© 1996-2019