2012-10-29 7 views
20

मेरा वेब ऐप jquery-ui और jqgrid के साथ एक बड़े आइकन सेट का उपयोग कर रहा है।
jquery-ui या jqgrid को अपग्रेड करते समय बड़े आइकन को समायोजित करने के लिए सीएसएस में परिवर्तनों को आसानी से बनाए रखने के लिए मेरे पास एक अलग सीएसएस फ़ाइल है जहां मेरे पास ओवरराइड का गुच्छा है।मैं एमवीसी के शैली बंडलिंग ऑर्डर को कैसे कॉन्फ़िगर कर सकता हूं?

जैसा कि आप कल्पना कर सकते हैं कि इस ओवरराइड फ़ाइल आवश्यक jquery-ui स्टाइलशीट और jqgrid शैली शीट के बाद शामिल किया जाना चाहिए।

मैं इतना

bundles.Add(new StyleBundle("~/Content/dark-hive/allstyles").Include(
    "~/Content/dark-hive/jquery-ui-1.8.23.custom.css", 
    "~/Content/ui.jqgrid.css", 
    "~/Content/jquery-ui-fixes.css", 
    "~/Content/icons.css", 
    "~/Content/site.css")); 

की तरह एक बंडल में मेरे सारे स्टाइलशीट डाल लेकिन ऐसा तरह गाया जा रहा है!

<link href="/Content/dark-hive/jquery-ui-1.8.23.custom.css" rel="stylesheet"/> 
<link href="/Content/jquery-ui-fixes.css" rel="stylesheet"/> 
<link href="/Content/ui.jqgrid.css" rel="stylesheet"/> 
<link href="/Content/icons.css" rel="stylesheet"/> 
<link href="/Content/site.css" rel="stylesheet"/> 

मैं सही क्रम में प्रस्तुत करने के लिए अपने बंडल को कैसे कॉन्फ़िगर कर सकता हूं?

अद्यतन
ठीक है, यह गूंगा है लेकिन यह काम करता है।

कोई फर्क नहीं पड़ता कि मैंने फ़ाइलों को हमेशा गलत तरीके से प्रस्तुत किया होगा। तो मैंने कुछ बेवकूफ और जोड़ा jquery-ui-fixes.css पहले और jquery-ui-1.8.23.custom.css आखिरी कोशिश की।

अचानक मेरे आदेश

<link href="/Content/jquery-ui-fixes.css" rel="stylesheet"/> 
<link href="/Content/dark-hive/jquery-ui-1.8.23.custom.css" rel="stylesheet"/> 
<link href="/Content/ui.jqgrid.css" rel="stylesheet"/> 
<link href="/Content/icons.css" rel="stylesheet"/> 
<link href="/Content/site.css" rel="stylesheet"/> 

मैं अपने जावास्क्रिप्ट jqueryuifixes.css करने के लिए फ़ाइल का नाम बदला और अब यह आदेश कम js फ़ाइलों में संरक्षित है है।

मुझे लगता है कि यदि स्टाइलशीट में नाम है - तो किसी कारण से इसे पहले प्राथमिकता दी जाती है और यह ऑर्डर अन्य फ़ाइलों के साथ बनाए रखा जाता है।

यदि कोई इसे समझा सकता है तो मैं उन्हें चेक दूंगा।

उत्तर

40

आप प्रत्येक फ़ाइल को व्यक्तिगत रूप से शामिल हैं, तो बंडल अपने आदेश का सम्मान करेंगे ...

var bundle = new Bundle("~/Content/dark-hive/allstyles", new StyleBundle());   
bundle.Include("~/Content/dark-hive/jquery-ui-1.8.23.custom.css"); 
bundle.Include("~/Content/ui.jqgrid.css"); 
bundle.Include("~/Content/jquery-ui-fixes.css"); 
bundle.Include("~/Content/icons.css"); 
bundle.Include("~/Content/site.css"); 
bundles.Add(bundle); 

अद्यतन

भी स्पष्ट आदेश का उपयोग कर, आप है कि वहाँ एक नहीं बल्कि उपयोगी अंतर्निर्मित मिल जाएगा ऑर्डरिंग सिस्टम में जो विशेष रूप से सभी अन्य लोगों के नाम पर फाइलों का नाम देता है। पूरी तरह से स्पष्ट यह पता है, तो आप उपयोग कर सकते हैं करने के लिए:

bundles.FileSetOrderList.Clear(); 

और आप का उपयोग कर अपने स्वयं के कस्टम आदेश जोड़ सकते हैं:

BundleFileSetOrdering ordering = new BundleFileSetOrdering("My Order"); 
ordering.Files.Add("jquery.js"); 

bundles.FileSetOrderList.Clear(); 
bundles.FileSetOrderList.Add(ordering); 

मूलतः, वहाँ फ़ाइलों को डाल दिया जाएगा के एक बड़े पैमाने पर निर्मित सूची है किसी भी फ़ाइल से पहले किसी निश्चित क्रम में जो सूची में नहीं है - लेकिन ये विकल्प आपको नियंत्रण लेने देते हैं।

+5

इस बंडल करने की मेरे लिए काम नहीं करता है चाहते हैं। –

+0

क्या यह अभी भी आदेश को सुरक्षित नहीं करता है या आपको कोई त्रुटि मिलती है? – Fenton

+2

ऑर्डर अभी भी गलत है, मुझे लगता है कि ऑप्टिमाइज़ेशन डीएल के संस्करण के साथ शायद कोई समस्या है जिसका मैं उपयोग कर रहा हूं। –

9

आप अपने कस्टम बंडलर बना सकते हैं और ओवरराइड OrderFiles विधि

public class CustomBundleOrderer : IBundleOrderer 
{ 
    public IEnumerable<FileInfo> OrderFiles(BundleContext context, IEnumerable<FileInfo> files) 
    { 
     return files; 
    } 
} 

तो क्रम में अपने सीएसएस फ़ाइलों पारित आप उन्हें

var bundle = new StyleBundle("~/Content/dark-hive/allstyles") 
{ 
    Orderer = new CustomBundleOrderer() 
}; 

bundle.Include(
    "~/Content/dark-hive/jquery-ui-1.8.23.custom.css", 
    "~/Content/ui.jqgrid.css", 
    "~/Content/jquery-ui-fixes.css", 
    "~/Content/icons.css", 
    "~/Content/site.css"); 

bundles.Add(bundle); 
+1

आईबंडलऑर्डरर के लिए हस्ताक्षर बदल गया है। सार्वजनिक आईनेमेरेबल ऑर्डरफ़ाइल (बंडल कॉन्टेक्स्ट संदर्भ, आईनेमेरेबल फाइलें) { वापसी फ़ाइलें; } – duyn9uyen

संबंधित मुद्दे