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

Calling a function within a function

3 Answers 35 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Chad
Top achievements
Rank 1
Chad asked on 07 Nov 2013, 02:53 PM
I have a Rad Autocomplete Box returning 3 values via web service, I also have several Rad windows on the page.  What I am trying to do is get those values from the auto complete box and load a certain Rad Window based on the values returned from the auto complete box.  I am having issues getting those values, when I try to grab the values and pass them to the rad window it conflicts with the select function.  I was wondering if there is a way to call a function inside a function, if so how do I accomplish this task?

Below is my code.

        function LoadWindow(Type) {
             var radDash = $find("<%= radDashboard.ClientID%>");
                      if (Type == 1) {
                          radDash.setUrl("ManageProcessor.aspx");
                      }
                      else if (Type == 2) {
                          radDash.setUrl("WoTracker.aspx");
                      }
                      else if (Type == 3) {
                          radDash.setUrl("WoTracker.aspx");
                      }
                      else if (Type == 4) {
                          radDash.setUrl("WoTracker.aspx");
                      }
                      else if (Type == 5) {
                          radDash.setUrl("PriorService.aspx");
                      }
                      else if (Type == 6) {
                          radDash.setUrl("WorkingRecruits.aspx");
                      }
                      radDash.show();
                      radDash.maximize();
         }
    </script>
    <script>       
         $(document).ready(function () {
             BindControls();
         });
         function BindControls() {
             $("#<%= txtSearch.ClientID%>").autocomplete({
                         source: function (request, response) {
                             $.ajax({
                                 url: "../Recruiting.asmx/FindRecID",
                                 data: "{ 'sLookUP': '" + request.term + "' }",
                                 dataType: "json",
                                 type: "POST",
                                 contentType: "application/json; charset=utf-8",
                                 dataFilter: function (data) { return data; },
                                 success: function (data) {
                                     response($.map(data.d, function (item) {
                                         return {
                                             label: item.split("-")[0],
                                             val: item.split("-")[1],
                                             ID: item.split("-")[2]
                                         }
                                     }))
                                 },
                                 error: function (response) {
                                     alert(response.responseText);
                                 }
                             });
                         },
 
                         select: function (e, i) {
                             $("#<%= HFRecruit.ClientID%>").val(i.item.val);
                             $("#<%= HFId.ClientID%>").val(i.item.ID);                            
                         },
 
                minLength: 2    // MINIMUM 1 CHARACTER TO START WITH.
            });
            }
    </script>
        <link href="../Recuiting.css" rel="stylesheet" />
    <link href="../Styles/Styles.css" rel="stylesheet" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="BodyContent" Runat="Server">
    <telerik:RadAjaxPanel ID="radajax" runat="server">
        <div style="width:auto">
            <div class="dvGridWrapper">
                    <asp:HiddenField ID="HFRecruit" runat="server" /><asp:HiddenField ID="HFId" runat="server" />
                    <asp:TextBox ID="txtSearch" runat="server" Width="260px" ToolTip="Enter Last Name First Name"></asp:TextBox>
                    <asp:TextBoxWatermarkExtender ID="txtSearch_WME" runat="server" TargetControlID="txtSearch" WatermarkText="Lookup Processor" WatermarkCssClass="Watermark"></asp:TextBoxWatermarkExtender>

    <div>
        <table  style="width:90%;margin-right:auto;margin-left:auto;margin-top:20px">               
            <tr>
                <td style="width:100%text-align:center">
                   <asp:HyperLink ID="hyEnlist" runat="server" onclick="LoadWindow(1)"><asp:Image ID="imgEnlist" runat="server" ImageUrl="../Images/SGT.jpg" CssClass="change_opacity" /></asp:HyperLink>&nbsp;Non-Prior Service
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:HyperLink ID="hyPrior" runat="server" onclick="LoadWindow(1)"><asp:Image ID="imgPrior" runat="server" ImageUrl="../Images/Corp.jpg" CssClass="change_opacity" /></asp:HyperLink>&nbsp;Prior Service
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:HyperLink ID="hyOfficer" runat="server" onclick="LoadWindow(2)"><asp:Image ID="imgOff" runat="server" ImageUrl="../Images/Cpt.jpg" CssClass="change_opacity" /></asp:HyperLink>&nbsp;Basic Branch
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                   <asp:HyperLink ID="HyWarrant" runat="server" onclick="LoadWindow(3)"><asp:Image ID="imgWarrant" runat="server" ImageUrl="../Images/W03.jpg" CssClass="change_opacity" /></asp:HyperLink>&nbsp;Warrant
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:HyperLink ID="hyGNPS" runat="server" onclick="LoadWindow(3)"><asp:Image ID="imgGNPS" runat="server" ImageUrl="../Images/glossary.jpg" CssClass="change_opacity" /></asp:HyperLink>&nbsp;Glossory Non Prior Service                  
                </td>
            </tr>
            <tr>
                <td style="padding-top:40pxtext-align:center">
                    <asp:HyperLink ID="hyIncentives" runat="server" onclick="LoadWindow(3)"><asp:Image ID="imgIncent" runat="server" ImageUrl="../Images/Incentive.jpg" CssClass="change_opacity" /></asp:HyperLink>&nbsp;Incentive Credit
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:HyperLink ID="hySpec" runat="server" onclick="LoadWindow(4)"><asp:Image ID="imgSpec" runat="server" ImageUrl="../Images/EFM.jpg" CssClass="change_opacity" /></asp:HyperLink>&nbsp;Specialty Branch
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<%--                    <asp:HyperLink ID="hyRFP" runat="server" onclick="LoadWindow(3)"><asp:Image ID="imgRFP" runat="server" ImageUrl="../Images/recruit.jpg" CssClass="change_opacity" /></asp:HyperLink>&nbsp;Recruit Force Pool
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--%>
                    <asp:HyperLink ID="hyIST" runat="server" onclick="LoadWindow(3)"><asp:Image ID="imgIST" runat="server" ImageUrl="../Images/IST.png" CssClass="change_opacity" /></asp:HyperLink>&nbsp;Interstate Transfer
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:HyperLink ID="hyDSE" runat="server" onclick="LoadWindow(3)"><asp:Image ID="imgDSE" runat="server" ImageUrl="../Images/toy2.jpg" CssClass="change_opacity" /></asp:HyperLink>&nbsp;Direct Service Enlistment 
                </td>
            </tr>
        </table>
    <telerik:RadWindow ID="radDashboard" runat="server" InitialBehaviors="Reload" ShowContentDuringLoad="false" CenterIfModal="true" Modal="true" Behaviors="Close" ></telerik:RadWindow>
        </div>    
    </telerik:RadAjaxPanel>
</asp:Content>

3 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 12 Nov 2013, 08:54 AM
Hello Chad,

Would you elaborate a bit more on the mentioned conflict which occurs when the values are passed to the select function? In addition, I would suggest you to open a support ticket, along with a runnable sample attached so we could be able to inspect the issue you had faced locally.

Regards,
Nencho
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Chad
Top achievements
Rank 1
answered on 12 Nov 2013, 03:12 PM
The three values I return via autocomplete box(label, val and ID).  I am trying to grab those values and open a rad window based on the values passed.  For example inside the j-Query select function I am trying to get those three values and call the Javascript load window function.  Every time I try to do so I somehow disable the select function.  The controls work fine so I did not see the need for a ticket to be submitted I was trying to find some insight on how to call the function within another function.  I can submit a ticket if needed though.  I hope this helps.

Chad-
0
Nencho
Telerik team
answered on 15 Nov 2013, 09:50 AM
Hello Chad,

As I can see, you are attempting to implement the jQuery autocomplete widget and it seems correct. Different use-cases are demonstrated in this documentation article. In addition, please refer to this thread, which you might find helpful.


Regards,
Nencho
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
AutoCompleteBox
Asked by
Chad
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Chad
Top achievements
Rank 1
Share this question
or