如何修复同位素中的Apend设计问题?

时间:2015-10-12 12:14:13

标签: javascript php jquery ajax append

我已经附加了ajax编码,数据正常,这里在追加style="position: absolute; left: 468px; top: 0px;" css时没有添加到我的新追加数据中。我怎样才能做到这一点?下面是我的ajax代码。请建议我。

See image here

<?php
 $per_page=20;
   $latestImages = mysql_query("select * from ".GIFIMAGES." WHERE isActive = '1' AND not_update='1'   order by modified ");
  $total_record=mysql_num_rows($latestImages)/5;
$maxPage=number_format((float) $total_record, 2, '.', '');

 ?>
<script>
    var lastX = 0;
            var currentX = 0;
            var page = 1;
            function loadMore() {
            if (page < '<?php echo $maxPage;?>') {
            page++;
            $('#load-more').html('Loading...');
              $.post("ajax_append.php", {'ajax_append':'<?php echo $per_page;?>','page':page},function(data)
         {
                 alert(data);

               $('#homeload').append(data);

                $('#load-more').html('VIEW MORE');
            });
            } else {
            $('#load-more').hide();
            }
            }



</script>

下面是外部(html)文件附加编码。(grid-splash-item)没有css正在调用同一个类,我已经在pageloading.plz中使用它来检查它。

                <?php
                $i=50; 
                $latestImages = mysql_query("select * from ".GIFIMAGES." WHERE isActive = '1' AND not_update='1'   order by modified DESC limit $total_records,$page_records");


                while($getLatestGif=mysql_fetch_array($latestImages)){
                $i++;
                $categoryName = mysql_fetch_array(mysql_query("select name from ".CATEGORY." where id='".$getLatestGif['cat_id']."'"));
                $checkLatestUsers = mysql_num_rows(mysql_query("select * from ". YEAH." where  user_id = '".$_SESSION['USER_ID']."' and gifimageid ='".$getLatestGif['id']."'"));
                $yeahCount = mysql_num_rows(mysql_query("select gifimageid from ". YEAH ."  where gifimageid = '".$getLatestGif['id']."'"));
                $yeahCountLatest = mysql_query("update ".GIFIMAGES." set yeahCount ='$yeahCount' where id = '".$getLatestGif['id']."'");
                $comment = mysql_query("select * from ".COMMENTS." where gifid='". $getLatestGif['id']."' order by id desc");
                $getLatestUser=mysql_fetch_array(mysql_query("SELECT username,photo FROM ".TBL_USERS." WHERE id='".$getLatestGif['userId']."'"));
                $commnetsCounts = mysql_num_rows($comment);
                ?>
                <div class="grid-splash-item">
                    <!--  <img src="images/img-2.jpg" /> -->
                    <a href="<?php echo HTTP_ROOT.'funny-'.$categoryName['name'].'-images/'. makeSeoUrl($getLatestGif['title']).'/'.$getLatestGif['uniq_id'];?>" >  <img  width="198" height="169" src="<?php echo HTTP_ROOT.DIR_GIF.$getLatestGif['gifphoto'];?>" /> </a>
                    <div class="gif-details">
                        <div class="gif-details-menu">
                            <span>
                                <div class="gif-details-menu-box" <?php if(!empty($_SESSION['USER_ID']) && $checkLatestUsers){?>  <?php } else {?> <?php } ?>>   

                                     //My coding present.I have removed it(too  long).
                                </div>
                            </span>
                            <p><a href="<?php echo HTTP_ROOT.'funny-'.$categoryName['name'].'-images/'. makeSeoUrl($getLatestGif['title']).'/'.$getLatestGif['uniq_id'];?>" title="<?php echo $getLatestGif['title'];?>" rel="tooltip"><?php echo substr($getLatestGif['title'],0,20);?></a></p>
                        </div>

                    </div>
                </div>
                <?php } ?>

2 个答案:

答案 0 :(得分:1)

尝试仅在html中添加内联css,

更改此

<div class="grid-splash-item">

<?php
    $counter = 1;
    while ($getLatestGif = mysql_fetch_array($latestImages)) {
        $i++;
        $categoryName = mysql_fetch_array(mysql_query("select name from " . CATEGORY . " where id='" . $getLatestGif['cat_id'] . "'"));
        $checkLatestUsers = mysql_num_rows(mysql_query("select * from " . YEAH . " where  user_id = '" . $_SESSION['USER_ID'] . "' and gifimageid ='" . $getLatestGif['id'] . "'"));
        $yeahCount = mysql_num_rows(mysql_query("select gifimageid from " . YEAH . "  where gifimageid = '" . $getLatestGif['id'] . "'"));
        $yeahCountLatest = mysql_query("update " . GIFIMAGES . " set yeahCount ='$yeahCount' where id = '" . $getLatestGif['id'] . "'");
        $comment = mysql_query("select * from " . COMMENTS . " where gifid='" . $getLatestGif['id'] . "' order by id desc");
$getLatestUser = mysql_fetch_array(mysql_query("SELECT username,photo FROM " . TBL_USERS . " WHERE id='" . $getLatestGif['userId'] . "'"));
        $commnetsCounts = mysql_num_rows($comment);

        if ($counter % 4 == 1) {
            $style = 'style="position: absolute; left: 0px; top: 175px;"';
        } else if ($counter % 4 == 2) {
            $style = 'style="position: absolute; left: 234px; top: 175px;"';
        } else if ($counter % 4 == 3) {
            $style='style="position: absolute; left: 468px; top: 175px;"';
        } else {
            $style='style="position: absolute; left: 702px; top: 175px;"';
        }
        $counter++;
?>
<div class="grid-splash-item" <?= $style ?>>
    <!--  <img src="images/img-2.jpg" /> -->
    <a href="<?php echo HTTP_ROOT . 'funny-' . $categoryName['name'] . '-images/' . makeSeoUrl($getLatestGif['title']) . '/' . $getLatestGif['uniq_id']; ?>" >  <img  width="198" height="169" src="<?php echo HTTP_ROOT . DIR_GIF . $getLatestGif['gifphoto']; ?>" /> </a>
    <div class="gif-details">
        <div class="gif-details-menu">
            <span>
                <div class="gif-details-menu-box" <?php if (!empty($_SESSION['USER_ID']) && $checkLatestUsers) { ?>  <?php } else { ?> <?php } ?>>   

                    //My coding present.I have removed it(too  long).
                </div>
            </span>
            <p><a href="<?php echo HTTP_ROOT . 'funny-' . $categoryName['name'] . '-images/' . makeSeoUrl($getLatestGif['title']) . '/' . $getLatestGif['uniq_id']; ?>" title="<?php echo $getLatestGif['title']; ?>" rel="tooltip"><?php echo substr($getLatestGif['title'], 0, 20); ?></a></p>
        </div>

    </div>
</div>

答案 1 :(得分:0)

经过大量的研究后,我得出了一个准确的结果。这里只需要改变两件事。在我用适当的css附加即将到来的罚款后,我没有写任何内联css。

下面是我的新代码。哪个工作正常。

这是我的新脚本编码。我修改了一点

<?php  $per_page=20; $latestImages = mysql_query("select * from ".GIFIMAGES." WHERE isActive = '1' AND not_update='1'   order by modified "); $total_record=mysql_num_rows($latestImages)/5;$maxPage=number_format((float) $total_record, 2, '.', ''); ?>
<script>
     $(function(){

            var $container = $('#container');
            var lastX = 0;
            var currentX = 0;
            var page = 1;
            $('#append a').click(function(){
            if (page < '<?php echo $maxPage;?>') {
            page++;
            $('.funny-gifts').html('Loading...');
            $.post("ajax_append.php", {'ajax_append':'<?php echo $per_page;?>','page':page},function(data)
         { 

        // $('#container').append(data);
        var $newItems = $(data);
         $('#container').isotope( 'insert', $newItems );
                   $('.funny-gifts').html('More Funny Gifs');
                  });
                  } else {
                  $('.funny-gifts').hide();
                  }

      });
  });
  </script>




    ***var $newItems = $(data);
     $('#container').isotope( 'insert', $newItems );***

以上两行编码对于附加非常重要。 不要使用$(&#39;#container&#39;)。append(data); for appending.Result会来,但有一个设计问题。然后稍微更换视图更多按钮.Below正在编码。

<div    id="append"><a href="javascript:;" onclick="loadMore()" class="funny-gifts">More Funny Gifs</a></div>