From afde9fd65fd6221b47504cc2c32d7f80c8654aa4 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 22 Nov 2015 22:25:34 -0500 Subject: ability to preload data --- StoneIsland/www/js/vendor/view/serializable.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'StoneIsland/www/js/vendor') diff --git a/StoneIsland/www/js/vendor/view/serializable.js b/StoneIsland/www/js/vendor/view/serializable.js index 83c7cdc3..a2ff1147 100644 --- a/StoneIsland/www/js/vendor/view/serializable.js +++ b/StoneIsland/www/js/vendor/view/serializable.js @@ -4,6 +4,28 @@ var SerializableView = View.extend({ "change select": "update_select", "focus input": "focus_input", }, + + preload: function(){ + if (sdk.env == "production") { return } + + this.test_data['ConfirmEmail'] = this.test_data['Email'] + Object.keys(this.test_data).forEach(function(key){ + + var value = this.test_data[key] + var $el = this.$("[name=" + key + "]") + + if ($el.attr("type") == "checkbox") { + $el.prop("checked", value) + } + else if ($el.prop("tagName") == "SELECT") { + $el.val( value ) + this.update_select({ currentTarget: $el }) + } + else { + $el.val( value ) + } + }.bind(this)) + }, serialize: function(){ var fields = {} -- cgit v1.2.3-70-g09d2