Hi Telerik,
Could I please have an example where the 'OnFocus' and 'OnBlur' events are successfully called after being applied to a RadListBox? I've tried numerous different approaches and none of them seem to work.
Sean
EDIT: Had to set the TabIndex property per HTML5 documentation -- http://www.w3.org/TR/html5/editing.html#attr-tabindex
EDIT2: Okay, so after playing around with this for a bit, I'm still not quite where I would like to be. I would like to attach a blur event to a dynamically created RadListBoxItem.
doesn't fire anything. What's the proper procedure?
EDIT3: So I've got something that works (mostly) but I'm not happy with... I can already think of one scenario it won't work in, in fact, but I figured I'd update.
So, the RadListBox's OnClientSelectedIndexChanged event seemed like a good place to start. I came to the conclusion that there's proooobably not a good way to set the focus to a RadListBoxItem. So, I've got this:
which will set focus to the radListBox responsible for the OnClientSelectedIndexChanged event. Unfortunately, this isn't quite sufficient for my purposes.
My goal is this:
I have a button on the page which has two states: 'Edit Text' or 'Add Item'. When a RadListBoxItem is focused I want the button to say 'Edit Text'. When the user clicks away from that item I want it to say 'Add Item.' The above code will work for some scenarios, but consider the following:
Ideally in that scenario I would deselect the item after detecting the blur event, but without the RadListBox blurring this is impossible...
Any advice on how to improve this design would be appreciated. Thanks.
Could I please have an example where the 'OnFocus' and 'OnBlur' events are successfully called after being applied to a RadListBox? I've tried numerous different approaches and none of them seem to work.
Sean
EDIT: Had to set the TabIndex property per HTML5 documentation -- http://www.w3.org/TR/html5/editing.html#attr-tabindex
EDIT2: Okay, so after playing around with this for a bit, I'm still not quite where I would like to be. I would like to attach a blur event to a dynamically created RadListBoxItem.
var
listboxItem = radListBox.get_selectedItem();
$(listboxItem.get_element()).blur(
function
() {
console.log(
"Item blurred."
);
});
doesn't fire anything. What's the proper procedure?
EDIT3: So I've got something that works (mostly) but I'm not happy with... I can already think of one scenario it won't work in, in fact, but I figured I'd update.
So, the RadListBox's OnClientSelectedIndexChanged event seemed like a good place to start. I came to the conclusion that there's proooobably not a good way to set the focus to a RadListBoxItem. So, I've got this:
function
OnClientSelectedIndexChanged(sender, eventArgs) {
console.log(
"ClientSelectedIndexChanged"
);
$telerik.$(radListBox1._getGroupElement()).focus();
which will set focus to the radListBox responsible for the OnClientSelectedIndexChanged event. Unfortunately, this isn't quite sufficient for my purposes.
My goal is this:
I have a button on the page which has two states: 'Edit Text' or 'Add Item'. When a RadListBoxItem is focused I want the button to say 'Edit Text'. When the user clicks away from that item I want it to say 'Add Item.' The above code will work for some scenarios, but consider the following:
- User has a RadListBox with room for 4 RadListBoxItems to be displayed.
- The RadListBox contains only 2 RadListBoxItems.
- The user selects the first RadListBoxItem. OnSelectedIndexChanged fires, and the jquery sets the RadListBox to focused.
- The user then clicks on a blank area of the RadListBox. Since the object is focused -- this doesn't change anything, but it 'feels' like to the user like they've clicked away from the item. Hence, the button should say 'Add Item'.
Ideally in that scenario I would deselect the item after detecting the blur event, but without the RadListBox blurring this is impossible...
Any advice on how to improve this design would be appreciated. Thanks.