findItemByText not working if text contains ampersand (&)

3 posts, 0 answers
  1. jlj30
    jlj30 avatar
    101 posts
    Member since:
    Jan 2011

    Posted 29 Apr 2015 Link to this post

    Hi,

    I have a contextual menu associated with a tabstrip.

    Here's the menu handler:

     

    function activityContextMenuClicked(sender, args) {
                    var itemValue = args.get_item().get_value();
                    if (itemValue == 'new') {
                        openActivityDialog('new', '', '', '');
                    } else if (itemValue == 'edit') {
                        var tabStrip = $find("<%= tbsActivities.ClientID %>");
                        var tab = tabStrip._findItemByText(args.get_targetElement().innerHTML);
                        var activityIDToUpdate = tab.get_value();
                        var activityName = tab.get_text();
                        var activityDesc = tab.get_attributes().getAttribute("Description");
                        openActivityDialog('edit', activityIDToUpdate, activityName, activityDesc);
                    } else if (itemValue == 'delete') {
                        var tabStrip = $find("<%= tbsActivities.ClientID %>");
                        var tab = tabStrip._findItemByText(args.get_targetElement().innerHTML);
                        activityIDToDelete = tab.get_value();
                        radconfirm("Are you really sure you want to delete this activity and all of its child elements?", deleteActivityResponse, 300, 100, null, "Delete Activity", null);
                    }
                }

    I must mention that the tabstrip is built dynamically, so the text is variable.

    The above code works fine unless the text contains an ampersand (I suspect other special characters may cause issues as well).

    I tried using findItemByValue(args.get_targetElement().value), but that did not work either.

     

    Any suggestions?

    Thanks

    Jim

     

     

  2. Dimitar
    Admin
    Dimitar avatar
    281 posts

    Posted 04 May 2015 Link to this post

    Hi Jim,

    The code snippet provided returns null for the "tab" variable and does not work on my side:

    var tab = tabStrip._findItemByText(args.get_targetElement().innerHTML);

    I would suggest you to find the tab in the following way:

    var tab = tabStrip.findTabByText(args.get_targetElement().textContent);

    This way it works on my side, no matter whether the RadTab contains an ampersand or not.

    Regards,
    Dimitar
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. jlj30
    jlj30 avatar
    101 posts
    Member since:
    Jan 2011

    Posted 04 May 2015 in reply to Dimitar Link to this post

    Hi Dimitar,

     

    Thanks for the code.

    It works great.

     

    Jim

Back to Top