Search code examples
javascriptphpjquerytwitter-bootstrapbootbox

bootstrap bootbox show variable in message


I would like to have the message in the dialog show something like "Choose how you want to kick/ban (playername)"

my current code looks like this

$(document).on("click", ".btn-ban", function(e) {
    var username = ($(this).attr('id'));
    bootbox.dialog({
       message: "Choose how you want to ban "+$username,
       title: "Ban Player",
       backdrop:false,
       buttons: {

didn't feel like the rest of the code mattered

i've tried taken the id from the ancor tag, which is defined by php to be the player name.

but ever since i added the "+$uername" to the message, the dialog wont show.

any ideas?


Solution

  • Its username not $username like,

    message: "Choose how you want to ban "+username,
    

    Full Code

    $(document).on("click", ".btn-ban", function(e) {
        var username = this.id; // you can use it simply without using attr()
        bootbox.dialog({
           message: "Choose how you want to ban "+username,
           title: "Ban Player",
           backdrop:false,
           buttons: {