javascript-events

jQuery Load Progress Bar

不问归期 提交于 2020-01-01 09:44:19
问题 So, I'm sure this question HAS to have been asked, but after searching through the 'Related Questions' here as well as several Google searches...I have come up empty. I'm simply trying to implement a true bytes_loaded/bytes_total type of progress bar in jQuery or even traditional Js. This was so easy in the AS3 days :) ...but of course Flash comes with it's drawbacks. All I really need to know is how to calculate the current bytes loaded and bytes total during any download. Calculating the

Dynamically add option to chosen select multiple JQuery plugin

你说的曾经没有我的故事 提交于 2020-01-01 09:33:26
问题 I want to add the text that a user inputs in the text field of a chosen select multiple input as an option, and automatically select it, all of this when the option doesn't exists, if the option exists, then I would like to select it. So far I have manage to do this: Chosen.prototype.add_text_as_option = function () { $('#id_select').append( $('<option>') .html(this.search_field.val()) .attr('selected', 'selected') .attr('value', 0) ); $('#id_select').trigger("liszt:updated"); return false; }

Dynamically add option to chosen select multiple JQuery plugin

血红的双手。 提交于 2020-01-01 09:33:25
问题 I want to add the text that a user inputs in the text field of a chosen select multiple input as an option, and automatically select it, all of this when the option doesn't exists, if the option exists, then I would like to select it. So far I have manage to do this: Chosen.prototype.add_text_as_option = function () { $('#id_select').append( $('<option>') .html(this.search_field.val()) .attr('selected', 'selected') .attr('value', 0) ); $('#id_select').trigger("liszt:updated"); return false; }

Bind events on AngularJS element directives using jQuery

浪子不回头ぞ 提交于 2020-01-01 09:22:32
问题 I have a directive in AngularJS: module = angular.module("demoApp", [], null); module.directive('sample', function () { return { restrict: "E", transclude: true, replace: true, template: "<div ng-transclude></div>", controller: function ($scope, $element) { this.act = function (something) { //problematic line HERE $element.trigger("myEvent.sample", [something]); }; } }; }) .directive('item', function () { return { restrict: "E", require: "^sample", transclude: true, replace: true, template: "

Temporarily disable all currently active jQuery event handlers

末鹿安然 提交于 2020-01-01 09:16:16
问题 I am making a TD element of table editable on double click: $(document).on("dblclick", "#table>tbody>tr>td.cell", function(e) { if (e.which != 1 || e.shiftKey || e.altKey || e.ctrlKey) // need left button without keyboard modifiers return; reset_selection(); var editor = document.createElement("div"); editor.setAttribute("contenteditable", "true"); editor.innerHTML = this.innerHTML; this.innerHTML = ''; // this.style.padding = 0; this.appendChild(editor); $(document).on("*", stub); editor

js: understanding how alert() impacts browser event loop

本秂侑毒 提交于 2020-01-01 08:04:13
问题 I'm considering adding an alert() to our javascript utility assert function. We're an ajax-heavy application, and the way our framework (Ext) implements ajax by polling for the ajax response with setInterval instead of waiting for readystate==4, causes all of our ajax callbacks to execute in a setInterval stack context -- and an exception/assert blowing out of it usually fails silently. How does a low-level alert() impact the browser event loop? The messagebox by definition must allow the

How to change characters typed in Firefox

谁都会走 提交于 2020-01-01 05:15:13
问题 I need to change in a text input the character '.' to ',' while typing. In IE I change the keyCode event property in the keypress event, like this document.getElementById('mytext').onkeypress = function (evt) { var e = evt || window.event; if (e.keyCode && e.keyCode==46) e.keyCode = 44; else if (e.which && e.which==46) { e.which = 44; } }; but it seemes that in Firefox it's impossible to change characters typed in key events. Any suggestions? 回答1: Try this. It works on all browsers: window

Fire a custom event with javascript (or jquery) when my function finishes

喜你入骨 提交于 2020-01-01 05:02:06
问题 Instead of having nested callbacks in JS, I would like to fire and listen to my own custom events. I don't need or want to access the DOM. Here's an example: function doSomething(){ //... $.trigger('finished-doSomething'); //fire the event 'finished-doSomething' } //when the event 'finished-doSomething' is fired -> execute the function in the second param $.live('finished-doSomething', function(){ alert("I finished-doSomething"); }); Would it be possible to do that with normal javascript code

callback for month, week, day title bar button clicks?

大憨熊 提交于 2020-01-01 04:51:24
问题 I need to run some javascript code to reload the calendar when the user either clicks, day/week/month buttons. Is there any callback like dayButtonClicked() or something? BUG happening: when i first load the calendar. The initial view looks fine mine initially loads day. As soon as i load another view such as week. Every single entry is duplicated and showing both sources of data. If i then click back and forward between day and month again the data is back to normal. What is happening is the

callback for month, week, day title bar button clicks?

╄→尐↘猪︶ㄣ 提交于 2020-01-01 04:51:12
问题 I need to run some javascript code to reload the calendar when the user either clicks, day/week/month buttons. Is there any callback like dayButtonClicked() or something? BUG happening: when i first load the calendar. The initial view looks fine mine initially loads day. As soon as i load another view such as week. Every single entry is duplicated and showing both sources of data. If i then click back and forward between day and month again the data is back to normal. What is happening is the