bootboxjs / bootbox

Wrappers for JavaScript alert(), confirm() and other flexible dialogs using Twitter's bootstrap framework
http://bootboxjs.com
Other
5.04k stars 1.04k forks source link

Modal dialog not working: undefined function #298

Closed joskuijpers closed 10 years ago

joskuijpers commented 10 years ago

Hi!

I am using Bootstrap 3.2, angular-bootstrap 0.11.0 and angular 1.2.21. I simply installed bootbox using bower install (4.3.0), and tried using

bootbox.alert('Hello World!');

This is what I get:

TypeError: undefined is not a function
    at Object.exports.dialog (http://localhost:3000/bower_components/bootbox/bootbox.js:689:16)
    at Object.exports.alert (http://localhost:3000/bower_components/bootbox/bootbox.js:307:24)
    at Scope.$scope.remove (http://localhost:3000/........./MY-controller.js:89:21)
    at http://localhost:3000/bower_components/angular/angular.js:10795:21
    at http://localhost:3000/bower_components/angular/angular.js:19036:17
    at Scope.$eval (http://localhost:3000/bower_components/angular/angular.js:12632:28)
    at Scope.$apply (http://localhost:3000/bower_components/angular/angular.js:12730:23)
    at HTMLButtonElement.<anonymous> (http://localhost:3000/bower_components/angular/angular.js:19035:21)
    at HTMLButtonElement.jQuery.event.dispatch (http://localhost:3000/bower_components/jquery/dist/jquery.js:4409:9)
    at HTMLButtonElement.elemData.handle (http://localhost:3000/bower_components/jquery/dist/jquery.js:4095:28) angular.js:10023

The 'dialog' variable, where the modal function is called on, does indeed not contain such function.

What is going on here? Might it be the angular ui bootstrap package?

Hope to hear what the troubles might be. I am wanting to use bootbox for error display and removal-confirmation.

joskuijpers commented 10 years ago

Erhm, I think I accidentally reformatted the whole bootbox.js file using my on-save JS beautify script. The top line of the bootbox.js stacktrace should read line 702.

makeusabrew commented 10 years ago

Hi @joskuijpers,

This is a classic symptom of the required Bootstrap JS not being loaded. I know you've mentioned it in your list of dependencies but it's worth double checking you're loading the JS, not just the CSS. Let me know if that's the cause - I might put a clearer console warning in about this.

makeusabrew commented 10 years ago

Warning error added, scheduled for 4.4.0 (#300)

joskuijpers commented 10 years ago

You are right! Thank you! I did not use the bootstrap JS because I use angular-bootstrap :)

ferozpuri commented 10 years ago

hi joskuijpers did you get solution yet... i also need to add bootbox in angular, but how can i do?

joskuijpers commented 10 years ago

The answer given above solved it for me :) I had to add the bootstrap javascrit file to my html.

On Nov 11, 2014, at 12:46 PM, Salman Ismail notifications@github.com wrote:

hi joskuijpers did you get solution yet... i also need to add bootbox in angular, but how can i do?

— Reply to this email directly or view it on GitHub.

EvanCarroll commented 9 years ago

Can we better check for the existence of Bootstrap.js? I mean, this will never be "hot" code. It would make more sense not to have everyone bit by this. Bootstrap.js does a reasonable job being sane about this. It's the very first thing it does..

if (typeof jQuery === 'undefined') {
  throw new Error('Bootstrap\'s JavaScript requires jQuery')
}

this question has detection code for Bootstrap.js v3.

// Will be true if bootstrap 3 is loaded, false if bootstrap 2 or no bootstrap
var bootstrap3_enabled = (typeof $().emulateTransitionEnd == 'function');

patch created

374