2013-09-30 48 views
0

我面临的是一个可疑的问题,它不能在逻辑上是真实的。在保存模型中,表格中的一些元素隐藏。保存模型隐藏tableview中的imageview

这里是视图代码noteRow.xml

<Alloy> 
    <TableViewRow id="noteRow"> 
     <View class="noteRowSeperator"></View> 
     <View id="noteRowContainer"> 
      <View class="noteSideBox"> 
       <ImageView id="noteStatus" onClick="toggleStatus"></ImageView> 
      </View> 
      <View class="noteContentBox"> 
       <Label class="noteDescription" text="{description}"/> 
      </View> 
     </View> 
     <View class="noteRowSeperator"></View> 
    </TableViewRow> 
</Alloy> 

这里是控制器代码noteRow.js

var moment = require('alloy/moment'); 

var id; 
if ($model) { 
    id = $model.id; 
    if ($model.get('done')) { 
     $.noteRowContainer.opacity = 0.5; 
     $.noteStatus.image = '/images/status_completed.png'; 
    } else { 
     $.noteRowContainer.opacity = 1; 
     $.noteStatus.image = '/images/status_not_completed.png'; 
    } 
} 

function toggleStatus(e) { 
    alert(id); 
    var note = Alloy.Collections.note.get(id); 

    note.set({ 
     "done": note.get('done') ? 0 : 1, 
     "completed_at": moment().format('X'), 
     "updated_at": moment().format('X') 
    }).save(); 
} 

当模型保存所有ImageView ID为noteStatus只是隐藏在所有的tableview tablerows。无法弄清楚为什么它有问题。请指导我对其进行分类。

应用类型:移动 钛SDK:3.1.2 平台:安卓(Gynemotion)(也是我的设备GALAXY SII上) 平台版本:4.1.1

+0

你有没有尝试添加一个按钮到表行和按钮的单击事件保存模型?只是为了测试。 –

+0

我试过了,但仍然是同样的问题。 –

回答

1

我终于想通了。问题出在view。我更新了视图。

<Alloy> 
    <TableViewRow id="noteRow"> 
     <View class="noteRowSeperator"></View> 
     <View id="noteRowContainer"> 
     <ImageView id="noteStatus" onClick="toggleStatus"></ImageView> 
      <View class="noteContentBox"> 
       <Label class="noteDescription" text="{description}"/> 
      </View> 
     </View> 
     <View class="noteRowSeperator"></View> 
    </TableViewRow> 
</Alloy> 

意味着简单地删除<View class="noteSideBox">解决了这个问题。不知道如何,但它解决了:)