$ (document) .ready (function () does not work perfectly in Content Pages / Telerik Controls

The pages of my project are based on the main and content pages ...

I want to do something with javascript (not jquery) on one of the content pages after ALL MASTER ELEMENTS AND CONTENTS ARE LOADED FULLY . (e.g. focus on the RadComboBox control)

For this, I used the code below:

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> <script src="../JQuery/jquery-1.4.1.js" language="javascript" type="text/javascript"></script> <script type="text/javascript"> onload = onloadOfDocument; function onloadOfDocument() { var combo = $find("<%= RadcbPersonelCompleteNameInvwNoskhehEdit.ClientID %>"); alert(combo); var comboInput = combo.get_inputDomElement(); comboInput.focus(); } </script> </asp:Content> 

But alert(combo); always returns null. (the $find code is for telerik controls, and the top telerik control codes are completely correct)

To solve this null problem, I am testing the methods shown below:

1- I removed all controls from the main page and content except RadComboBox Control, and the problem with zero disappeared, so I got a peoblem zero, about all elements of the wizard page and content were not loaded when

$find("<%= RadcbPersonelCompleteNameInvwNoskhehEdit.ClientID %>");

.

2- therefore I used

$(document).ready(function() { my codes });

instead

onload = onloadOfDocument;

but the problem is not solved - I do not know why !!!

3- finally, I am testing the code below and it works fine:

 <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> <script src="../JQuery/jquery-1.4.1.js" language="javascript" type="text/javascript"></script> <script type="text/javascript"> //onload = onloadOfDocument; document.onkeyup = onkeyupOfDocument; function onkeyupOfDocument() { var combo = $find("<%= RadcbPersonelCompleteNameInvwNoskhehEdit.ClientID %>"); alert(combo); var comboInput = combo.get_inputDomElement(); comboInput.focus(); } </script> 

What document function should I use to execute some javascript codes after all the MASTER AND CONTENT elements are fully loaded ?

Thanks in advance in advance

+4
source share
2 answers

the link below solved my problem: $ (document) .ready () and pageLoad () do not match!

my answer -> using pageLoad () instead of $ (document) .ready ()

+1
source

Is not it:

 var combo=$("#<%= RadcbPersonelCompleteNameInvwNoskhehEdit.ClientID %>")[0]; 

?

(Assuming RadcbPersonelCompleteNameInvwNoskhehEdit.ClientID resolves the id attribute of an element in the DOM)

0
source

Source: https://habr.com/ru/post/1316511/


All Articles