簡體   English   中英

我的onClick語法有什么問題?

[英]What is wrong with my onClick syntax?

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 -->

修改:

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

至:

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

當在兩個' (單引號)之間使用' (單引號)時,必須轉義單引號。 嘗試這樣:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM