rename in form $container to $div

This commit is contained in:
vitalets
2012-11-21 15:15:46 +04:00
parent 6a8cb83cbd
commit 76b4db77be

@ -11,7 +11,7 @@ Editableform is linked with one of input types, e.g. 'text' or 'select'.
var EditableForm = function (element, options) { var EditableForm = function (element, options) {
this.options = $.extend({}, $.fn.editableform.defaults, options); this.options = $.extend({}, $.fn.editableform.defaults, options);
this.$container = $(element); //div, containing form this.$div = $(element); //div (usually), containing form
this.initInput(); this.initInput();
}; };
@ -42,7 +42,7 @@ Editableform is linked with one of input types, e.g. 'text' or 'select'.
**/ **/
render: function() { render: function() {
this.$loading = $($.fn.editableform.loading); this.$loading = $($.fn.editableform.loading);
this.$container.empty().append(this.$loading); this.$div.empty().append(this.$loading);
this.showLoading(); this.showLoading();
this.initTemplate(); this.initTemplate();
@ -52,14 +52,17 @@ Editableform is linked with one of input types, e.g. 'text' or 'select'.
@event rendering @event rendering
@param {Object} event event object @param {Object} event event object
**/ **/
this.$container.triggerHandler('rendering'); this.$div.triggerHandler('rendering');
//render input //render input
$.when(this.input.render()) $.when(this.input.render())
.then($.proxy(function () { .then($.proxy(function () {
//place input
this.$form.find('div.control-group').prepend(this.input.$input); this.$form.find('div.control-group').prepend(this.input.$input);
//attach 'cancel' handler
this.$form.find('button[type=button]').click($.proxy(this.cancel, this)); this.$form.find('button[type=button]').click($.proxy(this.cancel, this));
this.$container.append(this.$form); //append form to container
this.$div.append(this.$form);
if(this.input.error) { if(this.input.error) {
this.error(this.input.error); this.error(this.input.error);
this.$form.find('button[type=submit]').attr('disabled', true); this.$form.find('button[type=submit]').attr('disabled', true);
@ -80,7 +83,7 @@ Editableform is linked with one of input types, e.g. 'text' or 'select'.
@event cancel @event cancel
@param {Object} event event object @param {Object} event event object
**/ **/
this.$container.triggerHandler('cancel'); this.$div.triggerHandler('cancel');
}, },
showLoading: function() { showLoading: function() {
var fw, fh, iw, ih; var fw, fh, iw, ih;
@ -110,7 +113,7 @@ Editableform is linked with one of input types, e.g. 'text' or 'select'.
@event show @event show
@param {Object} event event object @param {Object} event event object
**/ **/
this.$container.triggerHandler('show'); this.$div.triggerHandler('show');
}, },
error: function(msg) { error: function(msg) {
@ -171,7 +174,7 @@ Editableform is linked with one of input types, e.g. 'text' or 'select'.
if(params.newValue === 'username') {...} if(params.newValue === 'username') {...}
}); });
**/ **/
this.$container.triggerHandler('save', {newValue: newValue, response: response}); this.$div.triggerHandler('save', {newValue: newValue, response: response});
}, this)) }, this))
.fail($.proxy(function(xhr) { .fail($.proxy(function(xhr) {
this.error(typeof xhr === 'string' ? xhr : xhr.responseText || xhr.statusText || 'Unknown error!'); this.error(typeof xhr === 'string' ? xhr : xhr.responseText || xhr.statusText || 'Unknown error!');