Ben G
Ben G

Reputation: 253

Writing jQuery code combined with bootstrap

The jQuery code is like:

var $seatdiv = $('<div id = "seat'+i+'" class="seat-class"></div>')
.css({left: leftValue + 'px', bottom: bottomValue + 'px'});

I tried to add this "bootstrap" code, but it is not working:

$seatdiv.popover({content:row_label+" "row_name+"  " +column_label+ " "+column_name});

Who can tell me how I should write these code together? Cheers.

Upvotes: 0

Views: 151

Answers (1)

breezy
breezy

Reputation: 23

I am not too familiar with the bootstrap stuff, but by just looking at the code it seems like the jQuery selector is a little off. You should reference only by ID, so it would look more like:

var itemID = '#seat' + i;    
$(itemID).css(...);
$(itemID).popover(...);

jQuery selectors are just like CSS selectors: http://api.jquery.com/category/selectors/ -- ids are accessed with a '#' before their name, and items of a certain class are accessed with a '.' before the name of the class.

Also, reading through the docs (http://twitter.github.com/bootstrap/javascript.html#popovers), does your copy of bootstrap.js include the tooltip code? It is required.

All of your other code looks like it should work to me.

Upvotes: 1

Related Questions