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

findItemByText not working if text contains ampersand (&)

2 Answers 85 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
jlj30
Top achievements
Rank 2
jlj30 asked on 29 Apr 2015, 06:23 PM

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 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 04 May 2015, 10:56 AM
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.

 
0
jlj30
Top achievements
Rank 2
answered on 04 May 2015, 01:27 PM

Hi Dimitar,

 

Thanks for the code.

It works great.

 

Jim

Tags
TabStrip
Asked by
jlj30
Top achievements
Rank 2
Answers by
Dimitar
Telerik team
jlj30
Top achievements
Rank 2
Share this question
or