forked from minikomi/Bootstrap-Form-Builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnippet.js
More file actions
24 lines (24 loc) · 681 Bytes
/
snippet.js
File metadata and controls
24 lines (24 loc) · 681 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
define([
'jquery', 'underscore', 'backbone'
], function($, _, Backbone) {
return Backbone.Model.extend({
getValues: function(){
return _.reduce(this.get("fields"), function(o, v, k){
if (v["type"] == "select") {
o[k] = _.find(v["value"], function(o){return o.selected})["value"];
} else {
o[k] = v["value"];
}
return o;
}, {});
}
, idFriendlyTitle: function(){
return this.get("title").replace(/\W/g,'').toLowerCase();
}
, setField: function(name, value) {
var fields = this.get("fields")
fields[name]["value"] = value;
this.set("fields", fields);
}
});
});