2016-12-10 84 views
0

http://phpcodechecker.com/說'通知'是我的代碼中的(T_STRING)。我應該替換什麼?我的onClick語法有什麼問題?

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

回答

0

chnage這樣的:

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", 
+0

但的onclick函數只接受單一的報價 –

0

當你要在兩個'(單引號)之間使用'(單引號),您必須逃避單引號。試試這樣:

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

現在,它不會顯示任何錯誤,但不會的onClick顯示我的彈出式/粘性。你能檢查我的彈出腳本嗎? –

+0

檢查瀏覽器的控制檯。有沒有錯誤? –

+0

檢查元素及其未捕獲的SyntaxError中存在錯誤:意外的令牌: –