Monday, June 3, 2024
124
rated 0 times [  130] [ 6]  / answers: 1 / hits: 135869  / 12 Years ago, wed, august 22, 2012, 12:00:00

This seems a silly question but just got bootstrap and it doesn't gives any examples on the website about adding a Javascript callback to a button...



Tried setting my button an id flag and then



<div class=btn-group>
<button id=rectButton class=btn>Rectangle</button>
<button class=btn>Circle</button>
<button class=btn>Triangle</button>
<button class=btn>Line</button>
<button class=btn>Curve</button>
<button class=btn>Pic</button>
<button class=btn>Text</button>
<button class=btn>Gradient</button>
</div>


I want to add a callback to Rectangle button...



$('#rectButton').on('show', function (e) {
//ACTION
})


cant get the point of bootstrap callbacks.



All I could found on the web is oriented to Rails + Bootstrap... no bootstrap and JS only.


More From » jquery-events

 Answers
2

There is no show event in js - you need to bind your button either to the click event:



$('#id').on('click', function (e) {

//your awesome code here

})


Mind that if your button is inside a form, you may prefer to bind the whole form to the submit event.


[#83473] Tuesday, August 21, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cherish

Total Points: 734
Total Questions: 94
Total Answers: 86

Location: Senegal
Member since Fri, Aug 21, 2020
4 Years ago
;