k0sukey / alloy.widget.iconicfont

TiIconicFont (https://github.com/k0sukey/TiIconicFont) on Alloy widget.
Other
16 stars 5 forks source link

addEventListener doesn't work. #8

Open kratsg opened 11 years ago

kratsg commented 11 years ago
<Widget class="icon" id="test" icon="icon-facebook" src="be.k0suke.fontawesome" />

$.test.addEventListener('click',function(){alert('test');});

However, the fireEvent works just fine

$.test.fireEvent('test');

Secondary issue is that you can't use the selectedColor property (so you can get an icon to sort of act like a button.

Third issue is that inserting the widget inside a button like

<Button>
  <Widget />
</Button>

creates a top padding above the widget.

k0sukey commented 11 years ago

1, Try this code.

<Widget class="icon" id="test" icon="icon-facebook" src="be.k0suke.fontawesome" />

$.test.getView().addEventListener('click',function(){alert('test');});
$.test.getView().fireEvent('test');

2 and 3, This widget is Ti.UI.Label. So if you want to use the title of the Ti.UI.Button, then use the library here. This library to return the character code of icon.