Jquery移动输入可折叠问题

时间:2011-07-15 10:13:59

标签: javascript jquery android mobile jquery-mobile

我有一个可折叠时间列表,如屏幕截图..和下拉列表..在下拉列表中,您可以选择折叠时间如何分开时间..当我第一次打开活动时...它工作正常但是当我在droplist中选择了另一个时间,他更新了可折叠的输入丢失了他们的风格而没有工作..

enter image description here

这里是droplist change event->>

                    $('#timeDropList').change(function() {
                        $('div.addedEntry').remove();
                        drawTemplate();
                    });

这里是draw collapsibles function->>

        function drawTemplate() {
            var selectedValue = parseInt($('#timeDropList').val());

            var textProjectName = '<input type="text" class="projectName" value="" />';
            var textProjectData = '<input style="height:50px;" type="text" class="projectEntry" value="" />';

            var timespan;
            if ($('.div-cell').hasClass('tapped')) {
                var calToScheDate = $('.div-cell.tapped').find('.dayNumberCellValue')
                        .attr('data-a');

                var calToScheMonth;
                var calToScheDay;
                if (calToScheDay = calToScheDate.substring(6, 8) < 10) {
                    calToScheDay = calToScheDate.substring(7, 8);
                } else {
                    calToScheDay = calToScheDate.substring(6, 8);
                }
                if (calToScheMonth = calToScheDate.substring(4, 6) < 10) {
                    calToScheMonth = calToScheDate.substring(5, 6);
                } else {
                    calToScheMonth = calToScheDate.substring(4, 6);
                }
                timespan = new Date(calToScheDate.substring(0, 4), calToScheMonth,
                        calToScheDay, 9, 0);
            } else {
                timespan = new Date();
                timespan = new Date(timespan.getFullYear(), timespan.getMonth(),
                        timespan.getDate(), 9, 0);

            }


            while (timespan.getHours() < 18 || timespan.getHours() == 18
                    && timespan.getMinutes() == 0) {
                var hoursFrom = timespan.getHours();
                var minsFrom = timespan.getMinutes();
                if (minsFrom < 10) {
                    minsFrom = "0" + minsFrom;
                }
                if (hoursFrom < 10) {
                    hoursFrom = "0" + hoursFrom;
                }
                var hoursTo = timespan.getHours();
                var minsTo = timespan.getMinutes() + selectedValue
                if (minsTo == 60) {
                    minsTo = "00";
                    hoursTo++;
                } else if (minsTo < 10) {
                    minsTo = "0" + minsTo;
                }

                var collDiv = '<div class="addedEntry" data-theme="c" data-role="collapsible" id='+hoursFrom+minsFrom+hoursTo+minsTo+' data-collapsed="true"><h3 class="results-header">'
                        + hoursFrom
                        + ":"
                        + minsFrom
                        + " - "
                        + hoursTo
                        + ":"
                        + minsTo +'</h3>' + '</div>';
                $('.spanTimetable').append(collDiv);

                timespan.setMinutes(timespan.getMinutes() + selectedValue);
            }
            $('.addedEntry').append(textProjectName);
            $('.addedEntry').append(textProjectData);

            $('.results-header').append('<img class="checkOrCross" />');
            $('#timetable .addedEntry').collapsible({
                refresh : true
            });
        }

1 个答案:

答案 0 :(得分:0)

您需要使用.page()

刷新jQM

也许试试:

$('#timeDropList').change(function() {
    $('div.addedEntry').remove();
    drawTemplate();
});

$('#name of your page').page();