简体   繁体   English

生成的HTML代码不可点击

[英]Generated html code is not click-able

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... 帮帮我,我是ajax和jQuery框架的新手,我在jQuery中创建一个页面,使用一个不同的插件创建一个页面,但是当我从ajax接收html代码并且无法单击时,我使用了live()函数,但仅在插件删除方面有所帮助,而编辑插件不起作用,这可能是问题所在...

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 这是用于生成html的php代码

<?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 这是第一次在此网站上发布,对于错误和我的英语感到抱歉

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. 您正在运行$( 'EDITME')。编辑() 只有一次 ,的document.ready事件触发时。 editable() goes through the DOM at that time, and makes all the elements with class "editme" clickable. editable()当时遍历DOM,并使所有带有“ editme”类的元素都可单击。

When you add a post and get the response from your PHP script through AJAX, the response contains a P tag with class "editme". 当您添加帖子并通过AJAX从PHP脚本获取响应时,响应包含带有“ editme”类的P标记。 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. 但是由于这是在触发document.ready之后发生的,因此您将需要在此新页面元素上再次运行editable()使其可单击。

Big Thanks , i now that is really hard to understand the script , but is my first time to post here , and i have no idea how to ask ,your answer helped me , i put one more time to repeat the editable() inside the php script , response of ajax , and is working !!! 非常感谢,我现在真的很难理解该脚本,但是这是我第一次在这里发布脚本,而且我不知道如何问,您的回答对我有帮助,我又花了一些时间在脚本中重复editable() php脚本,ajax的响应,并且正在工作!!! ... Big Thanks again ! ...再次感谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM