यहाँ की तरह गतिशील contnet प्रस्तुत करना चाहिए के बाद मैंने अपने ढहने को गतिशील रूप से बदलने के लिए क्या किया है इसका एक उदाहरण। मेरे पास कुछ सरणी थीं जिन्हें मुझे हेडर के रूप में प्रदर्शित करने की आवश्यकता थी, और फिर मुझे 2 पक्षों के साथ प्रत्येक ढहने वाले सेट में एक ग्रिड की आवश्यकता थी, एक सवाल के लिए और एक उत्तर के लिए। jQuery Mobile docs: enhanceWithin
एक jQuery वस्तु अपने डोम तत्व के पेरेंट का प्रतिनिधित्व करने के लिए किसी भी jQuery मोबाइल अपने HTML करने के लिए जोड़ा सुविधाओं के लिए पर कॉल enhanceWithin
:
var inputList = '';
var count = 0;
var divnum = 999;
var collit = 'false';
inputList += '<div data-role="content">';
inputList += '<div id="fb_showings_collapse" data-role="collapsible-set" data-theme="b">';
$.each(fbFullStrArray, function(index, item) {
//set questions and answers for each appt
getsetApptFback(fbStrApptArray[index]);
//write the html to append when done
inputList += '<div data-role="collapsible" data-collapsed="'+collit+'">';
inputList += '<h3>'+fbFullStrArray[index]+'</h3>';
inputList += '<div id="g'+divnum+'" class="ui-grid-a">';
inputList += '<div id="gb'+divnum+'" class="ui-block-a">';
inputList += '<div id="fbq'+index+'"><ol>';
$.each(fbQidArray, function(ind,it) {
inputList += '<li>'+fbQuestionArray[ind]+'<b></b></li>';
});
inputList += '</ol></div></div>'
inputList += '<div id="ga'+divnum+'" class="ui-block-b">';
inputList += '<div id="fba'+index+'"><ul>';
$.each(fbQidArray, function(ind,it){
inputList += '<li>'+fbAnswerArray[ind]+'<b></b></li>';
});
inputList += '</ul></div></div></div></div>';
collit = "true";
divnum++;
count++;
});
inputList += '</div></div>';
$('#fb_showings_collapse [role=collapsible-set]').text('');
$('#fb_showings_collapse [role=collapsible]').text('');
if (count > 0) {
$('#fb_showings_collapse [role=collapsible]').remove();
$('#fb_showings_collapse').append(inputList).collapsibleset('refresh');
}
else if (count == 0){
inputList = 'Sorry! No Showings To Show Feedback For!';
$('#fb_showings_collapse [role=collapsible-set').remove();
$('#fb_showings_collapse [role=collapsible]').text(inputList);
}
स्रोत
2013-06-08 09:14:48
बहुत अच्छा कोड - धन्यवाद .... फॉलोअप सवाल, कैसे आप एक ही सहज आइटम में दो आइटम बारी चाहते हैं? – pithhelmet
@ पिथेलमेट - सुनिश्चित नहीं है कि मैं समझता हूं कि आप क्या करने के लिए कह रहे हैं, क्या आप थोड़ा सा स्पष्टीकरण दे सकते हैं? –
सुनिश्चित करें - आपका उदाहरण दो अलग-अलग आइटम दिखाता है, मैं एक शीर्षलेख और शीर्षक हूं ... वे एक स्थान से अलग होते हैं ... क्या उन दो वस्तुओं को एक निर्बाध बॉक्स में तोड़ने का कोई तरीका है ... इस http://jquerymobile.com/demos/1.0rc3/docs/content/content-collapsible.html#/demos/1.0rc3/docs/content/content-collapsible-set.html – pithhelmet