2016-04-02 20 views
0

gelen tarih seçme sonra Düğme Kodunu "Yeni Ekle": kod çalıştırmak yukarıdaki butona tıklamak sonradatepicker bootbox modal derisi

$('#AddButton').on('click', function() { 
       bootbox 
      .dialog({ 
       title: 'Add Transfer Details', 
       message: $('#userForm'), 
       show: false // We will show it manually later 
      }) 
      .on('shown.bs.modal', function() { 
       $('#userForm') 
        .show(); 
      }) 
      .on('hide.bs.modal', function(e) { 
       // Bootbox will remove the modal (including the body which contains the login form) 
       // after hiding the modal 
       // Therefor, we need to backup the form 
       $('#userForm').hide().appendTo('body'); 
      }) 
      .modal('show'); 
    }); 

ve bootbox açılan pencere gösterir. Bu modalın içinde datepicker var. Tarihçiden tarih seçtikten sonra, bootbox modalım hemen gizlenir.Lütfen bunun neden olduğuna dair yardım edin.

Benim datepicker kodu: GÜNCELLEME

$('#payDate').datepicker({ 
     format: 'dd-mm-yyyy', 
    }).on('changeDate', function(e){ 
     $(this).datepicker('hide'); 
    }); 

:

Jsfiddle bağlantı (Bu sorun Karşılıklı)

https://jsfiddle.net/paramj/sww1dnvk/3/

+0

mümkünse sorunun keman oluşturun olacak javascript

$('#userForm').hide().appendTo('body'); 

böylece bileşkesini kaldırmak burada

.on('hide.bs.modal', function(e) { // Bootbox will remove the modal (including the body which contains the login form) // after hiding the modal // Therefor, we need to backup the form $('#userForm').hide().appendTo('body'); }) 

yapılır. –

+0

'$ (this) .datepicker (' hide '); '' '(' payDate') .hide(); ' –

+0

@Kartikeya Khosla kemanının yaratıldığını kontrol etmeyi deneyin. – Paramjeet

cevap

0

Yayınladığınız sorun yanlış, modal gizlenmiyor. i 'Bu' onun seçerek giriş türü kullanıyorsanız zaman hiç çünkü Temel giriş

$(this).datepicker('hide'); 

$('#payDate').datepicker({ 
     format: 'dd-mm-yyyy', 
    }).on('change', function(){ 
     $('.datepicker').hide(); 
    }); 

ile

$('#payDate').datepicker({ 
     format: 'dd-mm-yyyy', 
    }).on('changeDate', function(e){ 
     $(this).datepicker('hide'); 
    }); 

değiştirin şu hattın sizin modal.because üzerinde metin alanını yazın Belge öğesi olarak metin ('id = payDate') alanı ve üzerine jquery gizle uygulanması.

Ve gaf pasajı

$('#AddButton').on('click', function() { 

      bootbox 
       .dialog({ 
        title: 'Add Transfer Details', 
        message: $('#userForm'), 
        show: true // We will show it manually later 
       }) 
       .on('shown.bs.modal', function() { 
        $('#userForm') 
         .show();        // Show the login form 
       }) 
       .on('hide.bs.modal', function(e) { 
        // Bootbox will remove the modal (including the body which contains the login form) 
        // after hiding the modal 
        // Therefor, we need to backup the form 

       }) 
       .modal('show'); 



     }); 
    $('#payDate').datepicker({ 
     format: 'dd-mm-yyyy', 
    }).on('change', function(){ 
     $('.datepicker').hide(); 
    }); 
+0

Kodunuz, yalnızca tarihçiyi tıkladıktan sonra tarih seçtiğimizde çalışır, ancak eğer tarih aralığı penceresini açarsak ve hemen ardından modal'ı tıklattıktan sonra formun içeriğini kaldırırız – Paramjeet

+0

Çözümü güncelliyorum. –

+0

Bahsetmek istediğim bir şey Gerçek kodumda aynı sayfada iki bootbox modal kullanıyorum Eğer bu kodu '$ (' # userForm ') kaldırırsam hide(). AppendTo (' body ');' sonra ilk kez açtıktan sonra sayfaları açamıyorum. İlk kez açıldıktan sonra bunlar sadece boş açılır pencereleri gösteriyor. Bunun neden olduğunu bilmiyorum ama bu kod onları açmaktan sorumlu. Bu kodu kaldırırsam sorun olur – Paramjeet