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

Dynamically adding tab with append, imageUrl and imageHtmlAttributes.

3 Answers 321 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Nathan
Top achievements
Rank 1
Nathan asked on 22 Jun 2012, 07:35 PM
I am trying to dynamically add a tab using the append method, but I cant get any of the imageHtmlAttributes to get inserted into the html.
Here is my code:

tabStrip.append(
    [{
        text: tabText,
        content: "<iframe style=\"width:100%\" src=\"" + url + "\"></iframe> ",
        imageUrl: "/Images/dialog_close_button.png",
        imageHtmlAttributes: { "onclick": "closeTab($(this).closest(\"li\"));" },
        collapsible: true
    }]
);

However the onclick is never added.

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 27 Jun 2012, 01:13 PM
Hello,

Setting the image HTML attributes with the append method is not supported. You should bind to the event with code in order to close the tab when the image is clicked.

Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Nathan
Top achievements
Rank 1
answered on 05 Jul 2012, 04:42 PM
Can you give example code, I assume you want me to use the select event but I do not know how to find whether the tab was clicked or the image itself was clicked.
0
Accepted
Daniel
Telerik team
answered on 09 Jul 2012, 02:35 PM
Hi,

Yes, the select even cannot be used to determine whether the image was clicked. If you need to perform the same action for the images in all tabs, you could use event delegation to bind to the image click event and execute your logic e.g.

$("#tabstrip").on("click"," .k-tabstrip-items .k-item img", function () {
 
});
If you need to handle to the appended element event, you could locate it by searching for the last item and bind to its image click event.

Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
TabStrip
Asked by
Nathan
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Nathan
Top achievements
Rank 1
Share this question
or