2014-11-21 71 views
1

林想知道是否有人可以幫我一點代碼。BootBox - 意外的標識符錯誤

我使用BootBox的某些Modal窗口,我想添加一些自定義的HTML到確認方法,但我不認爲我做對了。

我的代碼如下:

$('.next').click(function (event) { 
     event.preventDefault(); 
     var href = $(this).attr('href'); 
     bootbox.confirm({ 

      message: "I am a testing message", 
      title: "Please confirm you have enrolled" 

      callback: function (result) { 
       if (result) { 
        location.href = href; 
       }    
      } 

     }); 
    }); 

錯誤即時得到如下:

Uncaught SyntaxError: Unexpected identifier 

任何幫助將不勝感激。

乾杯,

+1

你在哪一行發生這個錯誤?? ..我認爲你有一個錯字...在標題後面有一個'''',請確認你已經註冊了'' – 2014-11-21 04:32:36

回答

4

你有一個語法錯誤的位置:

你的原代碼

title: "Please confirm you have enrolled" 
callback: function (result) { 
    if (result) { 
     location.href = href; 
    }    
} 

新代碼

title: "Please confirm you have enrolled", 
callback: function (result) { 
    if (result) { 
     location.href = href; 
    }    
} 

注 「」 CHARACT呃在title行的末尾。

+1

哦,我不能相信我錯過了...謝謝 – BigJobbies 2014-11-21 04:38:48

+0

[jsfiddle](http://jsfiddle.net/ty5Wc/26/),OPS你改變了你的評論 – 2014-11-21 04:57:48