Hi,
I have my own constructor of fields to make it more easily to build up / design. I have no problem rendering the field on the UI page, the problem is that… after the template was rendered all the fields, the materialize version of dropdown fields are not displaying even I put this code ‘$(’.dropdown-button’).dropdown()’ on onRendered method. Here’s the dropdown link of materialize http://materializecss.com/dropdown.html. Maybe the materialize can’t cater these numbers of fields? Or What? But so far it works when I limit the timeout of dropdown converter to 5 second… and that’s funny… the system user will punch me for sure if they have to wait that long…
Here’s how I rendered my fields builder {{{ _theFields }}}
Below is how the fields are being set.
_f.push({
type: "group",
gStart: '<div class="card tplcert-item" _ind="0"><div class="card-content">', //own html elements
gEnd: "", //own html elements
flds: []
});
_f.push({
type: "group",
gStart: '', //own html elements
gEnd: "", //own html elements
flds: [
{
type: "hidden",
label: "Comment",
name: "templates.certificate.0._id"
},
{
type: "select",
label: "Country",
name: "templates.certificate.0.country",
class: "country",
conClass: "s4",
option_attrb: {text: 'name', value: 'name'},
option_start: {text: '', value: ""},
options: countries
},
{
type: "select",
label: "State",
name: "templates.certificate.0.state",
class: "state",
conClass: "s4",
option_attrb: {text: 'name', value: 'name'},
option_start: {text: '', value: ""},
options: (_curr_data) ? getStatesByCountry(_curr_data.templates.certificate[0]['country']) : []
},
{
type: "select",
label: "Amount Type",
name: "templates.certificate.0.amount_type",
conClass: "s4",
option_start: {text: '', value: ""},
options: ['Any Amount', 'Above', 'Below', 'Betweem']
}
]
});
_f.push({
type: "group",
gStart: "", //own html elements
gEnd: "", //own html elements
flds: [
{
type: "select",
label: "Claim Type",
name: "templates.certificate.0.claim_type",
conClass: "s4",
option_start: {text: '', value: ""},
option_attrb: {text: 'name', value: 'name'},
options: claim_type_list,
required: true
},
{
type: "select",
label: "Incident Type",
name: "templates.certificate.0.incident_type",
conClass: "s4",
option_start: {text: '', value: ""},
option_attrb: {text: 'name', value: 'name'},
options: incident_list,
required: true
},
{
type: "select",
label: "Template File",
name: "templates.certificate.0.template",
conClass: "s4",
option_start: {text: '', value: ""},
options: ['10', '15'],
required: true
}
]
});
_f.push({
type: "div",
text: '<a href="#" class="removeTplBtn" key_ind="certificate" _target=".tplcert-item" style="color:red;">- Remove</a>'
});
_f.push({
type: "group",
gStart: '', //own html elements
gEnd: "</div></div>", //own html elements
flds: []
});
//----------------BEGIN-------------------//
if(_curr_data && _curr_data.templates.certificate.length > 1){
for(var _i = 1; _i <= (_curr_data.templates.certificate.length - 1); _i++){
_f.push({
type: "group",
gStart: '<div class="card tplcert-item" _ind="'+ _i +'"><div class="card-content">', //own html elements
gEnd: "", //own html elements
flds: []
});
_f.push({
type: "group",
gStart: '', //own html elements
gEnd: "", //own html elements
flds: [
{
type: "hidden",
label: "Comment",
name: "templates.certificate."+ _i +"._id"
},
{
type: "select",
label: "Country",
name: "templates.certificate."+ _i +".country",
class: "country",
conClass: "s4",
option_attrb: {text: 'name', value: 'name'},
option_start: {text: '', value: ""},
options: countries
},
{
type: "select",
label: "State",
name: "templates.certificate."+ _i +".state",
class: "state",
conClass: "s4",
option_attrb: {text: 'name', value: 'name'},
option_start: {text: '', value: ""},
options: (_curr_data) ? getStatesByCountry(_curr_data.templates.certificate[_i]['country']) : []
},
{
type: "select",
label: "Amount Type",
name: "templates.certificate."+ _i +".amount_type",
conClass: "s4",
option_start: {text: '', value: ""},
options: ['Any Amount', 'Above', 'Below', 'Betweem']
}
]
});
_f.push({
type: "group",
gStart: "", //own html elements
gEnd: "", //own html elements
flds: [
{
type: "select",
label: "Claim Type",
name: "templates.certificate."+ _i +".claim_type",
conClass: "s4",
option_start: {text: '', value: ""},
option_attrb: {text: 'name', value: 'name'},
options: claim_type_list,
required: true
},
{
type: "select",
label: "Incident Type",
name: "templates.certificate."+ _i +".incident_type",
conClass: "s4",
option_start: {text: '', value: ""},
option_attrb: {text: 'name', value: 'name'},
options: incident_list,
required: true
},
{
type: "select",
label: "Template File",
name: "templates.certificate."+ _i +".template",
conClass: "s4",
option_start: {text: '', value: ""},
options: ['10', '15'],
required: true
}
]
});
_f.push({
type: "div",
text: '<a href="#" class="removeTplBtn" key_ind="certificate" _target=".tplcert-item" style="color:red;">- Remove</a>'
});
_f.push({
type: "group",
gStart: '', //own html elements
gEnd: "</div></div>", //own html elements
flds: []
});
}
}
//----------------END-------------------//
_f.push({
type: "div",
text: '<a href="#" class="moreTplBtn" _target=".tplcert-item" style="float:right;">+ Add More</a>'
});
Is there any possibility for the meteor to wait first all functions that is being executed before rendering the template? Because since materialize works at 5 seconds for at least 84 fields, maybe the issue is because of sometimes the meteor reloaded the helpers every time there’s a script that touches the collection. As you can see on the fields designer that’s all dropdown with options from collections i.e Country, State, and others. So I’m not sure what is the problem.
For some suggestion to put a timeout my client dosn’t what it… because you have to calculate first for each dropdown how many data needs to loop as options before you’ll get the real estimated time.
Any suggestion and possible fixes are welcome, I tried all suggestions above but no luck yet.
Thanks!