How to pass values arguments to modal.show() function in Bootstrap

后端 未结 3 1663
时光取名叫无心
时光取名叫无心 2020-11-30 04:01

I have a page the shows a list of local cafes. When the user clicks on a certain cafe, a modal dialog is shown, that already has the \"cafe name\" pre-filled. The page conta

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-30 04:45

    You could do it like this:

    Announce
    

    Then use jQuery to bind the click and send the Announce data-id as the value in the modals #cafeId:

    $(document).ready(function(){
       $(".announce").click(function(){ // Click to only happen on announce links
         $("#cafeId").val($(this).data('id'));
         $('#createFormId').modal('show');
       });
    });
    

提交回复
热议问题