jquery-events

How do I get my accordion to load with all the menus closed?

半腔热情 提交于 2019-11-27 05:30:51
问题 I'm trying to follow the example here http://twitter.github.com/bootstrap/javascript.html#collapse I have placed a mockup here http://jsfiddle.net/gqe7g/ Loading behavior is strange. It shows Menu1 then collapses it then shows Menu2 and Menu3. I would like everything to open collapsed. I have tried the following without success $('#accordion').collapse({hide: true}) 回答1: Replacing $(".collapse").collapse(); $('#accordion').collapse({hide: true}) with: $('#collapseOne').collapse("hide");

How to pass values arguments to modal.show() function in Bootstrap

落爺英雄遲暮 提交于 2019-11-27 04:29:24
I have a page the shows a list of local cafes. When the user clicks on a certain cafe, a modal dialog is shown, that already has the "cafe name" pre-filled. The page contains many cafe names, and the form should contain the "cafe name" that he clicked on. Following is the list of cafe names generated as text with link button <table class="table table-condensed table-striped"> <tbody> <tr> <td>B&Js </td> <td>10690 N De Anza Blvd </td> <td> <a class="btn btn-primary" data-toggle="modal" onClick="$('#createFormId').modal('show')" >Announce</a> </td> </tr> <tr> <td>CoHo Cafe </td> <td>459 Lagunita

JQuery show/hide when hover

老子叫甜甜 提交于 2019-11-27 04:27:54
问题 I have three links, Cat, Dog, Snakes. When I hover over each, the content relating to each link should change. So if i hover over cat, then cat content will appear, if i hover over dog the cat content will smoothly disappear and the dog content will appear... and so on. Links are: Dog Cat Snake <div> <span style="display:none;"> Cat Content</span> <span style="display:none;"> Dog Content</span> <span style="display:none;"> Snake Content</span> </div> How do I get this to be full blown working

Twitter bootstrap stop propagation on dropdown open

丶灬走出姿态 提交于 2019-11-27 03:45:07
问题 I have a twitter bootstrap dropdown inside a div with the plugin jOrgChart. The problem I'm having is that when I click the button to open the dropdown menu it also triggers a click event in the parent div that does a collapse of other elements. This is my html: <div id="chart"> <div class="node"> <div class="btn-group"> <a class="btn dropdown-toggle" data-toggle="dropdown" href="#"> Actions <span class="caret"></span> </a> <ul class="dropdown-menu" style="text-align:left;"> <li><a href="#"

Run function after another one completes

感情迁移 提交于 2019-11-27 02:31:40
问题 function1 = function(){ something.on('transitionend', function(){ // now function2 should run }); } function2 = function(){ alert('ok'); } function1(); function2(); So I heard about jQuery promises. I would return a "deferred" object, and inside the event handler I would call deferred.resolve(); But what happens if i have multiple event handlers there and I only want the next function to run when all have been fired? + I don't like the idea of introducing something foreign like "deferred"

Monitoring when a radio button is unchecked

允我心安 提交于 2019-11-27 02:07:09
问题 I have an application that shows one div when a certain radio button is selected and then hides that div when the radio button is unselected. The problem is that the change event attached to the radio button only gets called when the radio button is checked, not when another one is checked (unchecking the previous one). My current code is as follows: <form name="newreport" action="#buildurl('report.filters')#" method="post"> <dl class="oneColumn"> <dt class="first"><label for="txt_name">Name<

Get clicked element using jQuery on event?

依然范特西╮ 提交于 2019-11-27 00:39:40
I'm using the following code to detect when a dynamically generated button is clicked. $(document).on("click",".appDetails", function () { alert("test"); }); Normally, if you just did $('.appDetails').click() you could use $(this) to get the element that was clicked on. How would I accomplish this with the above code? For instance: $(document).on("click",".appDetails", function () { var clickedBtnID = ?????? alert('you clicked on button #' + clickedBtnID); }); bipen As simple as it can be Use $(this) here too $(document).on("click",".appDetails", function () { var clickedBtnID = $(this).attr(

Bootstrap onClick button event

旧巷老猫 提交于 2019-11-26 20:37:26
问题 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=

return false from jQuery click event

随声附和 提交于 2019-11-26 19:45:29
I have click events set up like this: $('.dialogLink') .click(function () { dialog(this); return false; }); The all have a "return false" Can someone explain what this does and if it's needed? When you return false from an event handler it prevents the default action for that event and stops the event bubbling up through the DOM. That is, it is the equivalent of doing this: $('.dialogLink') .click(function (event) { dialog(this); event.preventDefault(); event.stopPropagation(); }); If '.dialogLink' is an <a> element then its default action on click is to navigate to the href . Returning false

jQuery .click() function called automatically

流过昼夜 提交于 2019-11-26 18:39:50
问题 I have an event listener set up on a button using jQuery, and for some reason the function within the click listener is called without the button being clicked. I know that usually functions are anonymous in listeners, but it won't work as an anonymous function. The function I am calling also has to accept parameters, which is why I don't think I can just call a reference to the function. Any ideas on how I can fix the problem of the function getting called without a click even registered and