annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
409da49c148d partway though add
drewp@bigasterisk.com
parents:
diff changeset
1 var model = {
5
f8c4c7ce5f4a lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents: 4
diff changeset
2 href: ko.observable(""),
f8c4c7ce5f4a lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents: 4
diff changeset
3 description: ko.observable(""),
f8c4c7ce5f4a lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents: 4
diff changeset
4 tag: ko.observable(""),
f8c4c7ce5f4a lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents: 4
diff changeset
5 extended: ko.observable(""),
f8c4c7ce5f4a lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents: 4
diff changeset
6 submitLabel: ko.observable("Add"),
4
409da49c148d partway though add
drewp@bigasterisk.com
parents:
diff changeset
7 };
409da49c148d partway though add
drewp@bigasterisk.com
parents:
diff changeset
8
409da49c148d partway though add
drewp@bigasterisk.com
parents:
diff changeset
9 ko.computed(function() {
409da49c148d partway though add
drewp@bigasterisk.com
parents:
diff changeset
10 if (model.href() == "") {
409da49c148d partway though add
drewp@bigasterisk.com
parents:
diff changeset
11 return;
409da49c148d partway though add
drewp@bigasterisk.com
parents:
diff changeset
12 }
409da49c148d partway though add
drewp@bigasterisk.com
parents:
diff changeset
13
5
f8c4c7ce5f4a lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents: 4
diff changeset
14 $.getJSON("addLink/proposedUri", {uri: model.href()}, function (data) {
f8c4c7ce5f4a lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents: 4
diff changeset
15 // these could arrive after the user has started typing in the fields!
f8c4c7ce5f4a lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents: 4
diff changeset
16
f8c4c7ce5f4a lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents: 4
diff changeset
17 model.description(data.description);
f8c4c7ce5f4a lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents: 4
diff changeset
18 model.tag(data.tag);
f8c4c7ce5f4a lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents: 4
diff changeset
19 model.extended(data.extended);
4
409da49c148d partway though add
drewp@bigasterisk.com
parents:
diff changeset
20
5
f8c4c7ce5f4a lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents: 4
diff changeset
21 model.submitLabel(data.existed ? "Update existing" : "Add");
f8c4c7ce5f4a lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents: 4
diff changeset
22
4
409da49c148d partway though add
drewp@bigasterisk.com
parents:
diff changeset
23 });
409da49c148d partway though add
drewp@bigasterisk.com
parents:
diff changeset
24
409da49c148d partway though add
drewp@bigasterisk.com
parents:
diff changeset
25 });
409da49c148d partway though add
drewp@bigasterisk.com
parents:
diff changeset
26
409da49c148d partway though add
drewp@bigasterisk.com
parents:
diff changeset
27 ko.applyBindings(model);