Search Context Events

4 posts, 0 answers
  1. Scott
    Scott avatar
    1 posts
    Member since:
    Nov 2011

    Posted 03 Dec 2013 Link to this post

    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?
  2. Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 06 Dec 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Albert Shenker
    Albert Shenker avatar
    551 posts
    Member since:
    Mar 2004

    Posted 25 Dec 2015 in reply to Plamen Link to this post

    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.
  5. Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 28 Dec 2015 Link to this post

    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
Back to Top