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

Search Context Events

3 Answers 76 Views
SearchBox
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 03 Dec 2013, 10:13 PM
I don't see any events, particularly client side events, associated with the new Search Context object.

What I would like to do is clear any typed text when the user chooses another item in the context list as I think this is more intuitive. 

Is there any way to detect a change of the Search Context selected item using script?

3 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 06 Dec 2013, 09:45 AM
Hi Scott,

Yes indeed in the current version of the SearchContext there aren't any predefined client events, however you can use some simple javascript to catch the click event of the item:

Copy Code
Copy Code
function pageLoad() {
               var $ = $telerik.$;
               $(".rsbPopup ").on("click", ".rsbListItem", function (e) {
                   e.preventDefault();
 
                   var itemData = Telerik.Web.UI.RadSearchBox._getTarget(e)._item;
                   alert(itemData.get_text());
               });
           }

We also have plans for adding such event in the control. You can vote for this feature and follow it here.

Regards,
Plamen
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
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
answered on 25 Dec 2015, 06:13 PM
This handler also handles the search results item being selected, which obviously is not desirable. How can I only handle the SearchContext item being selected? Also, any update on when there might be some actual client-side handlers for search context instead of fragile hacks. Its kind of frustrating the feature was released without such obvious functionality.
0
Plamen
Telerik team
answered on 28 Dec 2015, 06:18 AM
Hi Albert,

Thank you for the remark. Here is the updated code that handles only search context item click:
function pageLoad() {
            var $ = $telerik.$;
            $(".rsbSCSlide ").on("click", ".rsbListItem", function(e) {
                e.preventDefault();
 
                var itemData = Telerik.Web.UI.RadSearchBox._getTarget(e)._item;
                alert(itemData.get_text());
            });
        }


Regards,
Plamen
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
SearchBox
Asked by
Scott
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
Share this question
or