2017-06-22 1 views
0

Ich habe auf meinem Checkbox ein js Skript bekam aber Nachricht nichtjbox nicht zeigen Ankündigung

$('.js__test').on('change', function() { 
     const url = $(this).data('url'); 
     let data; 
     if (this.checked) { 
      data = '1'; 
     } else { 
      data = '0'; 
     } 
     $.post(url, data, function (data, status) { 
     }) 
      .done(function (data) { 
       new jBox("Notice", { 
        color: 'green', 
        content: 'success', 
       }); 
      }) 
    }); 

kommt Aber wenn ich Variablendefinition verwenden funktioniert es

var v = new jBox("Notice", { 
        color: 'green', 
        content: 'success', 
        }); 
       v.open(); 

Wie zu lösen dieses Problem?

+1

@Satpal ... Post it als Antwort? : S – obskyr

+0

@Satpal In diesem Fall sehe ich weiße Nachricht in der Mitte des Bildschirms. Es sollte ohne .open() funktionieren. Und ich frage, wie es geht. – Jens

Antwort

0

Es sieht so aus, als hätten Sie das Skript und die CSS-Datei nicht zur Benachrichtigung hinzugefügt. Bitte nehmen Sie diesen Tag in Ihrer Seite

<script src="//code.jboxcdn.com/plugins/Notice/jBox.Notice.js"></script> 
<link href="//code.jboxcdn.com/plugins/Notice/jBox.Notice.css" rel="stylesheet"/> 

$(document).ready(function() { 
 
    $('#myNotice').click(function() { 
 
    new jBox('Notice', { 
 
     content: 'Hurray! A notice!', 
 
     color: 'blue' 
 
    }); 
 
    }); 
 
});
<script src="//code.jquery.com/jquery-3.2.1.min.js"></script> 
 
<script src="//code.jboxcdn.com/0.4.8/jBox.min.js"></script> 
 
<link href="//code.jboxcdn.com/0.4.8/jBox.css" rel="stylesheet"> 
 
<script src="//code.jboxcdn.com/plugins/Notice/jBox.Notice.js"></script> 
 
<link href="//code.jboxcdn.com/plugins/Notice/jBox.Notice.css" rel="stylesheet"/> 
 
<div style="cursor: pointer" id='myNotice'>Just a div</div>

+0

In diesem Fall sehe ich weiße Nachricht in der Mitte des Bildschirms. Es sollte ohne .open() funktionieren. Und ich frage, wie es geht. – Jens

+0

Versuchte dies auch. Funktioniert immer noch nicht. – Jens

+0

Warum willst du 'open()' nicht benutzen? –