Created
February 20, 2017 19:07
-
-
Save preaction/d0f58e8d7027f1119f442bf3a74387e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mounted: function () { | |
var self = this; | |
/* Initialize state popover. We do this here in the constructor so | |
* we can initialize and still have a reference to the Vue component | |
* (self) to get information from | |
*/ | |
var popover = $( this.$el ).find( '[data-toggle="popover"].bmc_state' ); | |
popover.popover({ | |
placement: "auto right", | |
container: 'body', | |
trigger: 'focus', | |
html: true, | |
content: function () { | |
var content = self.state_text + ' (' + self.bmc.state + ')'; | |
if ( self.bmc.state == 3 ) { | |
content += '<br><a href="#" class="provision">Start Provisioning</a>'; | |
} | |
return content; | |
}, | |
}); | |
/* Delegate a provision handler to any link with the class | |
* "provision". We have to add these after the popover is | |
* shown because we can only add text (or html text) in the "content" | |
* property of the popover. | |
* See: http://stackoverflow.com/questions/13205103/attach-event-handler-to-button-in-twitter-bootstrap-popover | |
*/ | |
$(popover).on( 'shown.bs.popover', function () { | |
$('.popover .popover-content .provision').on( 'click', function () { | |
self.provision(); | |
} ); | |
} ); | |
$(popover).on( 'hidden.bs.popover', function () { | |
$( '.popover .popover-content .provision' ).off( 'click' ); | |
} ); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment