How to remove removeEventListener from tableView...
Hi guys.
I am using this eventListener for the row click (from kitchensink sample). When I refresh list the event is created again thus firing two times. I want to remove it with removeEventListener, so only current event stays. How can I modify the function below. I've tried several things, but non worked.
tableview_hitro.addEventListener('click',function()
{
var w = Titanium.UI.createWindow({title:lower_label.text});
var label2 = Titanium.UI.createWebView({html:'<html><body></body></html>'});
w.add(label2);
w.open({modal:true});
});
4 Answers
-
I wrote the solution. I run this function below on every refresh to clear the data and even. It works for now :)
//global var var tableview_event = null function tableview_clearData(table_view) { for (var c = 0;c < table_view.data.length;c++) { table_view.data[c].remove(); try { table_view.data[c].removeEventListener('click',tableview_event); } catch(ex){} } } function refresh() { tableview_clearData(table_view); tableview_event = table_view.addEventListener('click',function(e) { } }
-
var the_ev = tableview_hitro.addEventLi..... blah blah tableview_hitro.removeEventListener('click', the_ev);
is this working?
-
Hello.
Thank you for your answer Daniel. This way it does not work, because first it creates an event and secondly destroys it. I've also tried creating global counter to cancel the remove for the first time, but this works just partially, because as soon as new item is there it leaves the old data..
Is there any way to globally clear the data (and also the events from the tableview?
Thanks in advance.
-
add and remove don´t retrun anything….its type "void"….
but i can´t understand why i have to use function name to remove?!
if i add with addEventListener('click',function(e) {
i can not remove it…why?really anoing..