I am using ACS to query some posts. I have a file called "getPosts.js" which gets called when I focus on my mainWin like so:
mainWin.addEventListener('focus', function(){ if(Ti.App.Properties.getString('reload_main') == 'true') { data = require('getPosts').loadLatest(productsTable); Ti.App.Properties.setString('reload_main', 'false'); } });Here is what is going on in "getPosts.js":
function loadLatest(CurrentTable) { Cloud.Posts.query({ order:'-created_at', page: 1, per_page: 4 }, function(e){ if(e.success) { data = []; for(var i = 0; i < e.posts.length; i++) { data[i] = Titanium.UI.createTableViewRow({ width:300, height:Ti.UI.SIZE, selectedBackgroundColor:'transparent' }); // Some additional row items // Event for handling optionDialog and delete } CurrentTable.setData(data); } }); }Inside of my for loop, I am adding a button. This button creates an option dialog when clicked. One of these options is to delete the current row. Since this file is called from my main screen, I'm not sure how to delete the currently selected row. I'm not sure how to get the row index from inside of the "getPosts.js" file.
I am able to delete the post on the backend no problem using Cloud.Posts.remove. I'm just not sure about how to delete the row from the table.
Does anyone have any suggestions?