fix nuclear server render problem

This commit is contained in:
kmdjs 2016-05-22 08:03:38 +08:00
parent b4f36bf017
commit 6f3bf36d5a
3 changed files with 23 additions and 9 deletions

17
dist/nuclear.js vendored
View File

@ -1390,7 +1390,8 @@ Nuclear._mixObj = function (obj) {
this._nuclearTwoWay = true;
this._nuclearDiffDom = true;
this._nuclearServerRender = this._nuclearSetting.server;
if (this._nuclearSetting.twoWay === false) {
//close two way binding by default in node evn
if (this._nuclearSetting.twoWay === false||this._nuclearServerRender) {
this._nuclearTwoWay = false;
}
if (this._nuclearSetting.diff === false) {
@ -1452,8 +1453,7 @@ Nuclear._mixObj = function (obj) {
}
this._nuclearTimer = null;
this._preNuclearTime = new Date();
//server不用双向绑定
if(!this._nuclearServerRender)this._nuclearObserver();
this._nuclearObserver();
this._nuclearRenderInfo = {
tpl: this._nuclearTplGenerator(),
@ -1643,13 +1643,20 @@ Nuclear._mixObj = function (obj) {
};
obj._nuclearWrap = function (tpl) {
var scopedStr = "";
var scopedStr = "",optionStr="";
if (this.style) {
scopedStr = '<style scoped data-nuclearId=' + this._ncInstanceId + '>' + this.style() + '</style>';
}
return '<div '+(this._nuclearServerRender?'data-server="server"':'')+'>'+ scopedStr + tpl + '</div>'
if(this._nuclearServerRender){
optionStr=this._nuclearViewOption(this._ncInstanceId,JSON.stringify(this.option));
}
return '<div '+(this._nuclearServerRender?'data-server="server"':'')+'>'+ scopedStr + tpl +optionStr+ '</div>'
};
obj._nuclearViewOption = function(id,optionStr){
return '<input type="hidden" name="__nuclear_option_'+id+'" value=\''+optionStr+'\'>'
}
obj._nuclearLocalRefresh = function () {
var item = this._nuclearRenderInfo, rpLen = item.refreshPart.length;
item.tpl = this._nuclearTplGenerator();

4
dist/nuclear.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -266,13 +266,20 @@ Nuclear._mixObj = function (obj) {
};
obj._nuclearWrap = function (tpl) {
var scopedStr = "";
var scopedStr = "",optionStr="";
if (this.style) {
scopedStr = '<style scoped data-nuclearId=' + this._ncInstanceId + '>' + this.style() + '</style>';
}
return '<div '+(this._nuclearServerRender?'data-server="server"':'')+'>'+ scopedStr + tpl + '</div>'
if(this._nuclearServerRender){
optionStr=this._nuclearViewOption(this._ncInstanceId,JSON.stringify(this.option));
}
return '<div '+(this._nuclearServerRender?'data-server="server"':'')+'>'+ scopedStr + tpl +optionStr+ '</div>'
};
obj._nuclearViewOption = function(id,optionStr){
return '<input type="hidden" name="__nuclear_option_'+id+'" value=\''+optionStr+'\'>'
}
obj._nuclearLocalRefresh = function () {
var item = this._nuclearRenderInfo, rpLen = item.refreshPart.length;
item.tpl = this._nuclearTplGenerator();