view static/add.js @ 5:f8c4c7ce5f4a

lots of href additions: add/edit, nav fixes Ignore-this: 863335c4680ac9bcc6a7fc5867638d61
author Drew Perttula <drewp@bigasterisk.com>
date Thu, 21 Feb 2013 01:39:01 -0800
parents 409da49c148d
children e054949143e9
line wrap: on
line source

var model = {
    href: ko.observable(""),
    description: ko.observable(""),
    tag: ko.observable(""),
    extended: ko.observable(""),
    submitLabel: ko.observable("Add"),
};

ko.computed(function() {
    if (model.href() == "") {
        return;
    }

    $.getJSON("addLink/proposedUri", {uri: model.href()}, function (data) {
        // these could arrive after the user has started typing in the fields!
        
        model.description(data.description);
        model.tag(data.tag);
        model.extended(data.extended);

        model.submitLabel(data.existed ? "Update existing" : "Add");
        
    });
    
});

ko.applyBindings(model);