2010-11-04 40 views
6

我在一個頁面中使用多個UI主題。我使用css範圍創建自定義主題,可以說#scope。我使用範圍內的日期選擇器字段可以說#scope input#datepicker。 datepicker字段不會從UI主題獲取css樣式。我想這是因爲它是#scope以外的動態創建的,我該如何改變它,以及如何使它從範圍內獲取樣式。jQuery的日期選擇器出css範圍

回答

4

我解決了這個問題,在代碼中添加了一個wrapper div。

$(document).ready(function(){ 
    $("#ui-datepicker-div").wrap('<div class="ui-layout-center" />'); 
}); 
+0

只是爲了澄清「UI佈局中心」是您的自定義CSS類,是嗎?我個人儘量避免使用與其他jQuery UI中使用的ui-前綴相同的ui-前綴,以避免未來版本中可能的名稱衝突。 – 2013-08-28 01:34:08

0

我記得有同樣的問題,檢查一般定義的樣式如span,它可能與ui樣式重疊。

2

@bkilinc,你是對的。 datepicker日曆附加到document.body之後,並且位於自定義範圍之外。

http://bugs.jqueryui.com/ticket/4591 http://bugs.jqueryui.com/ticket/4306

在類似下面的結構中,日曆是容器的範圍之外。

<style type="text/css"> 
    .calendarContainer .ui-datepicker { 
     /* rule intended to affect only .calendarContainer */ 
    } 
</style> 
... 
<body> 
    <div class="calendarContainer"><input name="date"/></div> 
    <div class="ui-datepicker"> (generated calendar)</div> 
</body> 
相關問題