I am using the dataview to render some buttons dynamically with the actions are triggered by the “onbeforeselect” event. I have discovered that the event will not be triggered if the dataview contains an SVG image and throws the following error:
Uncaught TypeError: Object #<SVGAnimatedString> has no method 'split'
var starSVG = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="32px"'
+ ' height="32px" viewBox="0 0 32 32" style="enable-background:new 0 0 32 32;" xml:space="preserve">'
+ '<g id="Layer_1">'
+ '</g>'
+ '<g id="star">'
+ ' <g>'
+ ' <polygon class="svgIcon" points="22.137,19.625 32,12 20,12 16,0 12,12 0,12 9.875,19.594 6,32 16.016,24.32 26.008,32 '
+ ' "/>'
+ ' </g>'
+ '</g>'
+ '</svg>';
var applicationViews = [
{ buttonContent: "<div><div class='homepageImage'>" + starSVG + "</div><div class='homepageText'>Button 1</div></div>" }
];
{ view: "dataview", id: "buttons", datatype: "json", data: applicationViews,
type: { height: "auto",
width: "auto",
padding: "10px 10px 5px 10px",
template: "<button class='homepageButton'>#buttonContent#</button>"
}, select: true
}
$$("buttons").attachEvent("onbeforeselect", function() { dhx.alert("button pressed"); }));
Thanks,
James