-2

嗨,在我的脚本中,我使用了 Bootstrap 模式。问题是我在一段时间内接受它 - 功能。模态的第一个链接效果很好......打开模态和所有......但不是第二个,第三个......在那里我可以点击链接并且没有任何反应......有人知道吗?

    <?php while($row = mysql_fetch_array($data)){?>
    <td><a href="#<?php echo $row['id']; ?>" class="glyphicons no-js file_export" id="modal_ajax_demo_btn_<?php echo $row['id']; ?>" data-toggle="modal" title="Testversand"><i></i></a></td>

<div id="ajax-modal-<?php echo $row['id']; ?>" class="modal hide fade" tabindex="-1"></div>

        <script type="text/javascript">
        var UIModals = function () {

        var initModals = function () {

        $.fn.modalmanager.defaults.resize = true;
        $.fn.modalmanager.defaults.spinner = '<div class="loading-spinner fade" style="width: 200px; margin-left: -100px;"><img src="assets/img/ajax-modal-loading.gif" align="middle">&nbsp;<span style="font-weight:300; color: #eee; font-size: 18px; font-family:Open Sans;">&nbsp;Ladevorgang...</div>';


        var $modal = $('#ajax-modal-<?php echo $row['id']; ?>');


        $('#modal_ajax_demo_btn_<?php echo $row['id']; ?>').on('click', function(){
        // create the backdrop and wait for next modal to be triggered
        $('body').modalmanager('loading');
        user_id = $(this).attr('href').replace(/^#/,'');
        setTimeout(function(){

        $modal.load('send1.de', '', function(){
        $modal.modal();
        });
        }, 1000);
        });

        $modal.on('click', '.update', function(){
        $modal.modal('loading');
        setTimeout(function(){

        $.ajax({
        type: "POST",
        url: "send.php",
        data: "id=" + user_id + "&email=" + $("#email").val(),
        success: function(msg)
        {
        $modal
        .modal('loading')
        .find('.modal-body')
        .prepend('<div class="alert alert-success fade in">' +
        'All good!<button type="button" class="close" data-dismiss="alert"></button>' +
        '</div>');
        }
        });return false; 

        }, 5000);
        }); 

        }

        return {
        init: function () {
        initModals();
        }

        };

        }();
        </script>
        </tr>
        <?php } ?> 
4

1 回答 1

0

好的我明白了。问题是初始化我的javascript函数的函数。现在它起作用了。当然,我也必须在上面的函数var UIModals = function () {中使用 while id 更改它。

我只用过:

<script>
    jQuery(document).ready(function() {       
            UIModals.init();
    });
</script>

但我需要使用:

<script>
    jQuery(document).ready(function() {   
   <?php while($rowinit = mysql_fetch_array($init)){ echo'UIModals'.$rowinit['id'].'.init();';}?>
    });
</script>
于 2013-07-30T21:25:46.060 回答