我正在开发一个使用Meteor-1.6 + Blaze +实现的应用程序,并创建一个多模态模板,例如aModal,bModal,cModal..etc,并在按钮上将这些模板调用到主模板中,单击使用ReactiveVar。
getModalTemplate() {
return Template.instance().modalTemplate.get() || '';
},
getModalData () {
return Template.instance().modalData.get() || '';
}
DynamicModalTemplate& modalData是帮助程序,为模态提供动态选择的模态模板和数据。
助手:
'click #carModalTrigger' (event, inst) {
import ('./cars.js').then(() => {
inst.modalTemplate.set("carsModal");
Meteor.setTimeout(() => {
$("#carsModal").modal();
$("#carsModal").modal('open');
}, 200)
});
},
'click #brandingSectionTrigger' (event, inst) {
import ('./bikes.js').then(() => {
inst.modalTemplate.set("bikeModal");
Meteor.setTimeout(() => {
$("#brandingSection").modal();
$("#brandingSection").modal('open');
}, 200)
});
}
活动:
this.autorun(() => {
const dataHandle = Meteor.subscribe('myCollection');
if (dataHandle.ready()) {
console.log("==> SubsReady ::: ", dataHandle);
let vData = {};
vData = MyCollection.find({ userId: Meteor.userId() }).fetch();
this.modalData.set(vData);
console.log("=> vData ",vData)
}
}
}
设置模态数据变量:
public class JsonHandler {
static String response = null;
public final static int GET = 1;
public final static int POST = 2;
public JsonHandler() {
}
public String makeServiceCall(String url,int method) {
return this.makeServiceCall(url, method, null);
}
public String makeServiceCall(String url, int method,
List<NameValuePair> params) {
try {
// http client
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpEntity httpEntity = null;
HttpResponse httpResponse = null;
// Checking http request method type
if (method == POST) {
HttpPost httpPost = new HttpPost(url);
if (params != null) {
httpPost.setEntity(new UrlEncodedFormEntity(params));
}
httpResponse = httpClient.execute(httpPost);
} else if (method == GET) {
if (params != null) {
String paramString = URLEncodedUtils.format(params, "utf-8");
url += "?" + paramString;
}
HttpGet httpGet = new HttpGet(url);
httpResponse = httpClient.execute(httpGet);
}
httpEntity = httpResponse.getEntity();
response = EntityUtils.toString(httpEntity);
} catch (Exception e) {
}
return response;
}
}
modalData是动态更新但是模态显示旧数据,比如当我打开汽车模态它显示正确的数据但是在关闭它之后如果modalData更新并且我再次打开汽车模态它显示我的旧数据没有更新一个。
当我打开Bikes模态并关闭它时显示更新的数据,现在再次打开汽车模式将显示更新的数据。
请指导我如何在打开模态时加载更新的数据。
感谢。