user1813251
user1813251

Reputation: 339

breeze not detecting changes

using durandal/require/breeze/knockout

When I make a change to a value in the text box in the table. breeze is not detecting a change. manager.hasChanges() always returns false. Why is breeze not finding that change?

Controller

    [HttpGet]
    public object Lookups()
    {
        var categories =  _contextProvider.Context.KMS_Categories;
        var tags = _contextProvider.Context.KMS_Tag;
        return new { categories, tags };
    }

getting Data

    var manager = configureBreezeManager(),
    EntityQuery = breeze.EntityQuery;

    return EntityQuery.from('Lookups')
    .using(manager).execute()
    .fail(queryFailed);

save changes function

   var saveChanges = function () {
    return manager.saveChanges()
    .then(saveSucceded)
    .fail(saveFailed)

    function saveSucceded(saveResult) {
        log('Saved data successfully', saveResult, true);
    }

    function saveFailed(error) {
        var msg = 'Save failed: ' + error.message;
        logError(msg, error);
        error.message = msg;
        throw error;
    }
}

Table displaying data and where being changed

  <table class="table table-bordered table-hover table-striped table-condensed">
            <thead>
                <tr>
                    <th>Tags</th>
                </tr>
            </thead>
            <tbody data-bind="foreach: adminTags">
                <tr>
                <td ><input class="form-control" data-bind="value: $data.Tag()" /></td>
                </tr>
            </tbody>
        </table>

Upvotes: 2

Views: 227

Answers (1)

nemesv
nemesv

Reputation: 139758

Your binding is incorect, you need to write $data.Tag

<input class="form-control" data-bind="value: $data.Tag" />

With writing $data.Tag() you are not binding to your observable property itself but you are binding directly to its underlying value which makes your binding effectively one-way only.

Demo JSFiddle.

Upvotes: 3

Related Questions