Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery datepicker out of css scope

I am using multiple ui themes in one page. I create a custom theme with a css scope, lets say #scope. I use a datepicker field in the scope lets say #scope input#datepicker. the datepicker field does not get css styles from the the ui theme. I guess this is because it is dynamically created outside of #scope, how can I alter this, and how can make it to get styles from scoped.

like image 335
bkilinc Avatar asked Nov 04 '10 14:11

bkilinc


2 Answers

I solved this problem with adding a wrapper div in code.

$(document).ready(function(){
    $("#ui-datepicker-div").wrap('<div class="ui-layout-center" />');
});
like image 107
bkilinc Avatar answered Oct 21 '22 22:10

bkilinc


@bkilinc, you are correct. The datepicker calendar is appended to document.body, outside of your custom scope.

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

In a structure like the following, the calendar is outside of the scope of the container.

<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>
like image 2
Monte Hayward Avatar answered Oct 21 '22 22:10

Monte Hayward