Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

searchbar.fireEvent('change') called from tabbedBar doesn't work

The following code does not work…

var ui = Ti.UI;
var win = ui.currentWindow;

var mySearch  = ui.createSearchBar({ top: 0, height: 44});
var myTabbed  = ui.createTabbedBar({ labels:['A', 'B', 'C'], index: 0, top: 44 });
var mySpace   = ui.createButton({ systemButton: Ti.UI.iPhone.SystemButton.FLEXIBLE_SPACE });
var myToolbar = ui.createToolbar({ items: [mySpace, myTabbed, mySpace] });

myTabbed.addEventListener('click', function(e) {
    mySearch.fireEvent('change');
});

mySearch.addEventListener('change', function(e) {
    alert('Event 'change' was triggered!');
});

win.add(mySearch);
win.add(myToolbar);

Any ideas? Thanks :)

— asked April 9th 2010 by Cedric Kastner
  • fireevent
  • iphone
  • searchbar
  • tabbedbar
2 Comments
  • I'm curious about it too.

    — commented June 25th 2010 by Caio Iglesias
  • Did you escape the aposthropes in the alert?

    — commented October 21st 2011 by Kristof Gruber

1 Answer

  • FYI: I'm currently using the following workaround:

    mySearch.setValue(mySearch.value);
    
    — answered April 9th 2010 by Cedric Kastner
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.