我的onClick语法有什么问题?

时间:2016-12-10 05:01:48

标签: php

http://phpcodechecker.com/说我的代码中的“通知”是(T_STRING)。我该怎么替换'?

<?php 
    $Query = $this->DBase('Query', array( 0 => "SELECT * FROM `factions`" ));
    while ($FACTIONS = $Query->fetch_object()) {
        $this->FACTION->FACTIONSLIST .= 
        '<tr class="even pointer">
            <td width="1%" class="a-center "><input type="checkbox" class="flat" name="table_records"></td>
            <td width="10%">{$FACTIONS->id}</td>
            <td>{$FACTIONS->Name} </td>
            <td width="5%" class="last">
                <a href="{SITE_CMS_ROOT}?factions&edit={$FACTIONS->id}">
            &nbsp;<i class="fa fa-pencil"></i>
                </a>
            &nbsp;&nbsp;&nbsp;&nbsp;
            <a href="{SITE_CMS_ROOT}?factions&delete={$FACTIONS->id} onclick="alert(Alrt Text!);"></a>
                <a href="#" onclick="new TabbedNotification([
                    title: 'Notification',
                    text: 'Faction 123 successfully deleted!, page will be updated shortly.',
                    type: 'Error',
                    sound: false
                ]);">
                    <i class="fa fa-trash-o"></i>
                </a>
            </td>
        </tr>';
    }    
?>

这是带有onClick脚本的HTML。 {SITE_FACTIONS}是带有onClick函数的php脚本。

<body class="nav-md">
    <div class="container body">
        <div class="main_container">
            {SITE_SIDEBAR}
            {SITE_NAVIGATION}
            <div class="right_col" role="main">
                <div class="">
                    <div class="page-title">
                        <div class="title_left">
                            <h3> </h3>
                        </div>
                        <div class="title_right">
                            <div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search">
                                <div class="input-group">
                                    <input type="text" class="form-control" placeholder="Search for...">
                                    <span class="input-group-btn">
                                        <button class="btn btn-default" type="button">Go!</button>
                                    </span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="clearfix"></div>
                    <div class="row">
                        <div class="clearfix"></div>
                        {SITE_FACTIONS}
                    </div>
                </div>
            </div>
            {SITE_FOOTER}
        </div>
    </div>

<div id="custom_notifications" class="custom-notifications dsp_none">
  <ul class="list-unstyled notifications clearfix" data-tabbed_notifications="notif-group">
  </ul>
  <div class="clearfix"></div>
  <div id="notif-group" class="tabbed_notifications"></div>
</div>

<!-- jQuery -->
<script src="{SITE_CMS_ROOT}vendors/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="{SITE_CMS_ROOT}vendors/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- FastClick -->
<script src="{SITE_CMS_ROOT}vendors/fastclick/lib/fastclick.js"></script>
<!-- NProgress -->
<script src="{SITE_CMS_ROOT}vendors/nprogress/nprogress.js"></script>
<!-- bootstrap-progressbar -->
<script src="{SITE_CMS_ROOT}vendors/bootstrap-progressbar/bootstrap-progressbar.min.js"></script>
<!-- iCheck -->
<script src="{SITE_CMS_ROOT}vendors/iCheck/icheck.min.js"></script>
<!-- PNotify -->
<script src="{SITE_CMS_ROOT}vendors/pnotify/dist/pnotify.js"></script>
<script src="{SITE_CMS_ROOT}vendors/pnotify/dist/pnotify.buttons.js"></script>
<script src="{SITE_CMS_ROOT}vendors/pnotify/dist/pnotify.nonblock.js"></script>

<!-- Custom Theme Scripts -->
<script src="{SITE_CMS_ROOT}build/js/custom.min.js"></script>

<!-- Custom Notification -->
<script>
  $(document).ready(function() {
    var cnt = 10;

    TabbedNotification = function(options) {
      var message = "<div id='ntf" + cnt + "' class='text alert-" + options.type + "' style='display:none'><h2><i class='fa fa-bell'></i> " + options.title +
        "</h2><div class='close'><a href='javascript:;' class='notification_close'><i class='fa fa-close'></i></a></div><p>" + options.text + "</p></div>";

      if (!document.getElementById('custom_notifications')) {
        alert('doesnt exists');
      } else {
        $('#custom_notifications ul.notifications').append("<li><a id='ntlink" + cnt + "' class='alert-" + options.type + "' href='#ntf" + cnt + "'><i class='fa fa-bell animated shake'></i></a></li>");
        $('#custom_notifications #notif-group').append(message);
        cnt++;
        CustomTabs(options);
      }
    };

    CustomTabs = function(options) {
      $('.tabbed_notifications > div').hide();
      $('.tabbed_notifications > div:first-of-type').show();
      $('#custom_notifications').removeClass('dsp_none');
      $('.notifications a').click(function(e) {
        e.preventDefault();
        var $this = $(this),
          tabbed_notifications = '#' + $this.parents('.notifications').data('tabbed_notifications'),
          others = $this.closest('li').siblings().children('a'),
          target = $this.attr('href');
        others.removeClass('active');
        $this.addClass('active');
        $(tabbed_notifications).children('div').hide();
        $(target).show();
      });
    };

    CustomTabs();

    var tabid = idname = '';

    $(document).on('click', '.notification_close', function(e) {
      idname = $(this).parent().parent().attr("id");
      tabid = idname.substr(-2);
      $('#ntf' + tabid).remove();
      $('#ntlink' + tabid).parent().remove();
      $('.notifications a').first().addClass('active');
      $('#notif-group div').first().css('display', 'block');
    });
  });
</script>
<!-- /Custom Notification -->

2 个答案:

答案 0 :(得分:0)

chnage this:

title: "Notification",
text: "Faction 123 successfully deleted!, page will be updated shortly.",
type: "Error",

为:

<a href="https://www.facebook.com/ricardo.berumenborrego" target="_blank">
  <img src="https://s6.postimg.org/4ya8t5ce9/Facebook.png" alt="https://www.google.com.mx" style="width:42px;height:42px;border:0"><a href="https://www.linkedin.com/in/ricberbor3" target="_blank">
  <img src="https://s6.postimg.org/u6zo0k6pt/Linkedin.png" alt="https://www.google.com.mx" style="width:42px;height:42px;border:0">
</a><a href="https://www.behance.net/ricardoberbor" target="_blank">
  <img src="https://s6.postimg.org/4hp16pon5/Behance.png" alt="https://www.google.com.mx" style="width:42px;height:42px;border:0">
</a><a href="https://pinterest.com/ricardoberbor/" target="_blank">
  <img src="https://s6.postimg.org/9o4rvhssh/Pinterest.png" alt="https://www.google.com.mx" style="width:42px;height:42px;border:0">
</a><br><a href="https://www.jovoto.com/community/RicardoBerumen" target="_blank">
  <img src="https://s6.postimg.org/3kn7bl2ip/Jovoto.png" alt="https://www.google.com.mx" style="width:42px;height:42px;border:0">
</a><a href="https://www.bevisible.soy/users/10058" target="_blank">
  <img src="https://s6.postimg.org/82kwpxt6p/Be_Visible.png" alt="https://www.google.com.mx" style="width:42px;height:42px;border:0">
</a><a href="https://dribbble.com/ricardoberbor" target="_blank">
  <img src="https://s6.postimg.org/xmn6wdekh/Dribbble.png" alt="https://www.google.com.mx" style="width:42px;height:42px;border:0">
</a>

答案 1 :(得分:0)

当您在两个'(单引号)之间使用'(单引号)时,您必须转义单引号。试试这样:

title: \'Notification\',
text: \'Faction 123 successfully deleted!, page will be updated shortly.\',
type: \'Error\',