This is a migrated thread and some comments may be shown as answers.

OnClientEntryAdded Firing Client-Side Before Page is Ready

1 Answer 87 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
License
Top achievements
Rank 1
License asked on 04 Nov 2014, 03:25 PM
I have a form where I'm using an AutoCompleteBox to allow users to select a client from the database and create some information to attach to that client. If the client doesn't already exist, I have a quick input form on the same page that allows them to add the new client to the database. This triggers a server-side event that inserts the client info and returns the Client Name and an automatically generated Client ID that I use to create a token for AutoCompleteBox.

I'm using the OnClientEntryAdded & OnClientEntryRemoved events to control whether the Add Client form inputs are enabled or disabled. Basically, if a token exists, they cannot add a new client to the database. This works if I load a token through the AutoCompleteBox. The input fields are cleared and disabled when a token is loaded and reenabled if all tokens are removed from the AutoCompleteBox.

The issues occurs when I fire the server-side click event for the Add Client information. I insert the new record and create a token that I add to the AutoCompleteBox then the OnClientEntryAdded event automatically fires once all the server-side events are complete. The logical operator shown below in my sample script works. It correctly finds that the AutoCompleteBox now has 1 entry but then when it tries to clear and disable the textbox, it throws a null or undefined object error. The best I can determine, is that the OnClientEntryAdded is fired before the textboxes are available in the DOM but I have no idea how to workaround this. Any help is appreciated.

function NewClientInputsToggle(sender, eventArgs) {
    if ($find("<%= racClientSearch.ClientID %>").get_entries().get_count() == 0) {
        $find("<%= txtNewClient.ClientID %>").enable();
    }
    else {
        $find("<%= txtNewClient.ClientID %>").clear();
        $find("<%= txtNewClient.ClientID %>").disable();
     }
}

1 Answer, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 07 Nov 2014, 11:56 AM
Hello Robert,

I would like to ask you to provide us with the markup and the declaration of the RadAutoCompleteBox that you use at your end, in order to get a clearer picture on the faced issue and pinpoint the problem. Also, if any additional logic or implementation is needed for the replication of the problem - please provide them also.

Regards,
Nencho
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
AutoCompleteBox
Asked by
License
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Share this question
or