donglu9743 2009-08-25 22:09
浏览 36
已采纳

生成的html代码无法点击

Help me please i'm a newbie in ajax and framework jQuery , i make in jQuery a page , with different plugins a page , but when i receive html code from ajax ,and is not click-able , i used a function live() , but only helped on plugin delete , with edit plugin is not working , what can be the problem...

This is script for editing

<script type="text/javascript">
    $(document).ready(function() {
        $('.editme').editable('func/update_data.php', {
            submitdata: {
                type: "<?php echo $page_type?>"
            },
            cancel: 'Cancel',
            submit: 'OK',
            tooltip: 'Click to edit...',
            id: 'element_id',
            name: 'update_value',

        });
    });
</script>

this is the script for plugin modal window and

$(document).ready(function () {
    $('#basicModal input.basic, #basicModal a.basic').click(function (e) {
        e.preventDefault();
        $('#basicModalContent').modal({
            onOpen: function (dialog) {
                dialog.overlay.fadeIn('slow', function () {
                    dialog.data.hide();
                    dialog.container.fadeIn('slow', function () {
                        dialog.data.slideDown('slow');
                    });
                });
            },
            onClose: function (dialog) {
                dialog.data.fadeOut('slow', function () {
                    dialog.container.hide('slow', function () {
                        $.modal.close();
                    });
                });

            }
        });

    });

    $("form#submit_wall").submit(function () {
        var message_wall = $('#message_wall').attr('value');
        $('#message_wall').val('');
        $.ajax({
            type: "POST",
            url: "func/insert.php",
            data: "message_wall=" + message_wall,
            dataType: "html",
            complete: function () {
                $('#basicModalContent').html('<div class="succes"><p>Successful</p> Your record was posted  ! </div>');
                setTimeout(function () {
                    $.modal.close()
                },
                1200);
            },
            success: function (response) {
                $("div#wall").html(response);
                //$("div#wall").prepend("<span style='display:none'>"+message_wall+"</span>");
                //$("div#wall span").fadeIn();
            }
        });
        return false;
    });

});

this is php code for generating html

<?php if(isset($_POST[ 'message_wall'])){ 
  /* Remove HTML tag to prevent query injection */ 

  $message=strip_tags($_POST[ 'message_wall']); 
  echo '<div class="container_date">
          <span style="float: left;"> 
            <p class="editme" id="200">Sex</p> 
          </span>
          <span style="float: right;" align="left"> 
            <a href="javascript:void(0)" id="200" class="delete">Delete</a>  
          </span>
          <br class="clearfloat">
        </div>'; 
} ?>

this is first time for posting on this site , sorry for mistakes and for my english

  • 写回答

2条回答 默认 最新

  • donglu8334 2009-08-26 00:09
    关注

    It is very hard to understand what you want, but it looks to me like this:

    You are running $('.editme').editable() only once, when the document.ready event fires. editable() goes through the DOM at that time, and makes all the elements with class "editme" clickable.

    When you add a post and get the response from your PHP script through AJAX, the response contains a P tag with class "editme". But since this happens after document.ready has fired, you will need to run editable() again on this new page element to make it clickable.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值