0

I am facing a suspicious issue which can't be logically true. On Saving model the some elements in tablerow hides.

Here is the view code 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>

Here is the controller code 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();
}

When the model saves the all ImageView with id noteStatus simply hides on all tablerows in tableview. Can't figure out why its having the issue. Please guide me to sort it.

Application type: Mobile Titanium SDK: 3.1.2 Platform: Android (Gynemotion) (Also on my device Galaxy SII) Platform Version: 4.1.1

Nazar Hussain
  • 5,102
  • 6
  • 40
  • 67

1 Answers1

1

I finally figured it out. The problem was with view. I updated the view to.

<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>

Means simply removing <View class="noteSideBox"> solved the issue. Don't know how but it solved :)

Nazar Hussain
  • 5,102
  • 6
  • 40
  • 67