2012-10-17 23 views
0

與動態內容實例日期選擇器,當我遇到一個奇怪的問題顯示一次。 設置:使用PHP注入的HTML,與jQuery和AJAX一起編程。日期選擇器只能在動態內容

我有jquery.ui.datepicker.mobile.js運行。

當我點擊一個鏈接,它加載的頁面,因爲它應該。當我返回並再次單擊該鏈接時,datepicker不顯示(輸入字段確實具有'hasDatepicker'類)。現在

,我發現,如果我在另一頁上,轉到頁與鏈接,然後單擊它,它不顯示的日期選擇器,甚至不是第一次了。

$('.productSaleLink').live('click',function() { 
    var prod = $(this).attr('data-params'); 
    $.post("product.php",{product:prod}, function(data){ 
     $('#productContent').html(data); 
     $.mobile.changePage('#productsale', {transition: 'slide'}); 
     $('.currentProduct').listview(); 
     $('.sellLink').button(); 
     $(':input').textinput(); 
     $('.date').datepicker().css({'background-color':'red'}); 
    }); 

    return false; 
}) 

product.php:

$html = "<ul class='currentProduct' data-role='listview' data-theme='d' data-divider-theme='d'>"; 

while($row2 = mysql_fetch_array($products)) 
{ 
    $html .= "<li class='lis'>"; 
    $html .= "<h3>".$row2['brand']." ".$row2['product']."</h3>"; 
    $html .= "<p><span style='color:#666'>Serial:</span> <span style='font-weight:bold;'>".$row2['serial']."</span>,<span style='color:#666'> Product-ID:</span> ".$row2['product_id']."</p>"; 
    $html .= "<p><span style='color:#666'>Bought:</span> ".$row2['buying_date']."<span style='color:#666'> From:</span> <span style='font-weight:bold;'>".$row2['seller']."</span></p>"; 
    $html .= "<input class='client' style='display:inline;margin-right:5px;' type='text' name='client' id='client' value='Client' onfocus='if($(this).val()==\"Client\")$(this).val(\"\");' onblur='if($(this).val()==\"\")$(this).val(\"Client\");' />"; 
    $html .= "<input class='date' style='display:inline;' type='date' name='date' id='".$row2['id']."' value='Date' />"; 
    $html .= "<p class='ui-li-aside'>"; 
    $html .= "<a class='sellLink' data-params='".$row2['id']."&3p&".$_SESSION['username']."' href='sell.php' data-role='button' data-inline='true' data-theme='a'>Sell</a>"; 
    $html .= "</p>"; 
    $html .= "</li>"; 
} 

$html .= "</ul>"; 
echo $html; 

任何幫助嗎?

+0

用螢火蟲調試。你可以看到hasDatepicker類是否有效或無效 –

回答

0

嘗試在所有$(...).datepicker('destroy');(或所有電流)初始化新的之前日期選擇器領域。

+0

類型錯誤:研究所是未定義 inst.append.remove(); –

+0

你有問題上傳到哪裏我們將能夠看到它的行動? – zeddotes

+0

你可以在這裏看到它:http://www.blinkblink.eu/tests/登錄與測試測試。然後點擊一個產品,然後你看到日期輸入框(第一次) –

相關問題