javascript-events

How to customize edit event in JsGrid

天涯浪子 提交于 2019-12-25 07:25:18
问题 I'm using jsGrid and wanna know if it's possible how to customize onclick event of editButton. Basically, doing something like displaying modal instead of inline editing. I know that we can get the HTML output of control column like this : { type: 'control', itemTemplate: function() { var $result = jsGrid.fields.control.prototype.itemTemplate.apply(this, arguments); // Array of string return $result; } } But how to have control on EditButton ? Thanks for your help. 回答1: You can try this:

Where should I bind a global event in jQuery

浪尽此生 提交于 2019-12-25 07:13:59
问题 I am wondering if I want to create a custom global event listener, where I should bind that event. Which one should I use? $(window).trigger('someEvent'); or $(document).trigger('someEvent'); or $('body').trigger('someEvent'); For example, there is a site in which it has home, about-us, news and some other pages. Each pages has its own javascript file, i.e. home.js, about-us.js.. and so on. And there's one common javascript file, main.js, which serves all the core or common functions

Passing parameters to $(window).on('resize') when using .trigger('resize')

不想你离开。 提交于 2019-12-25 06:58:16
问题 S/O! I need a reliable way to detect if $(window).on('resize') has been fired by user interaction or by a jQuery .trigger call. I've tried the following, but I don't seem to get the parameters back in the function call: $(window).trigger('resize',[true]); function prepareOnResize(e, triggered){ console.dir(triggered); } $(window).on('resize',prepareOnResize); Triggered seems to return the width of the screen, so I tried the following, also to no avail: $(window).trigger('resize',[true]);

Trying to write a script to push a box using mouse pointer in Javascript

假如想象 提交于 2019-12-25 06:57:34
问题 I'm in the beginning of learning Javascript, and trying to write a script that allows the user to push a box left and right using mouse pointer. I managed to work it out when the pointer touches the left side of the box, but i'm facing two problems here : When the pointer gets inside the box, the box jumps to the new coordinate. I want the box to stay in it's position when the pointer gets inside the box. I really can't figure it out when the mouse touches the right side of the box. I want

Call a function when the content inside a div is changed?

女生的网名这么多〃 提交于 2019-12-25 06:47:11
问题 I have a page, on the left there is a list of links users can click, when they are clicked, a div on the right side will load the correct content via Ajax according to the link. Now I want to fire a function when the right side div's content changed every time. After a search in SO, I learn that there are Mutation Events, I use the DOMSubtreeModified event: right_div.addEventListener("DOMSubtreeModified", handler, false); However, when I click the link on the left side, it seems that handler

Do Javascript bindings take up memory while not in use?

让人想犯罪 __ 提交于 2019-12-25 06:44:28
问题 I have a calendar that I've built, and on clicking a day on the calendar, a function is run. You can go month to month on the calendar, and it generates months as it goes. Since every day on the calendar, shown or not, is binded to an event using the class of all the "days," I'm worried about the number of "bindings" building up into the thousands. //after a new month is generated, the days are rebound TDs.off("mousedown"); TDs = $(".tableDay"); TDs.on("mousedown", TDmouseDown); While I was

Trigger a built in event in javascript? [duplicate]

你。 提交于 2019-12-25 05:38:08
问题 This question already has answers here : Manually dispatchEvent DOMContentLoaded (2 answers) Closed 2 years ago . I noticed that you can make and trigger your own customs events and event listeners in javascript like this. Can I do something similar to trigger a pre-existing event artificially? For example say I'm loading external javascript and I want to artificially trigger DOMContentLoaded after the event has actually fired. 回答1: // Code goes here document.addEventListener(

Javascript Multistep form won't update variable value outside of function when returning the updated variable

蹲街弑〆低调 提交于 2019-12-25 04:57:10
问题 I'm working on a multi-step donation form which transitions between steps by using javascript. Sadly, when returning the value from the function, it is not updating the value. Changing step is done using this function: function showNextStep(currentStep) { var chosenDonationType, checkedAllocations, selectedAllocationValue; $("#step" + currentStep).slideToggle("slow", function () { if (currentStep === 1) { //figure out what kind of donation they are making chosenDonationType = $("[name

How to pass/escape an argument to an event handler attached using javascript?

僤鯓⒐⒋嵵緔 提交于 2019-12-25 04:36:24
问题 In the code HTML+Script below, an event handler is attached after page load using setAttribute(...) . The event hander is passed an argument which is read dynamically too. the event hander is attached successfully ( verified by a getAttribute(...) However, the handler does not fire. What is wrong with the snippet below? <HTML> <BODY onload="loader();"> <table> <tbody> <tr> <td id="myId">FirstColumn</td> <td id="otherId">SecondColumn</td> <td id="lastId">Balderdash</td> </tr> </tbody> </table>

How to check if some DOM element in another DOM element tree?

余生长醉 提交于 2019-12-25 04:22:22
问题 How to check if some DOM element in another DOM element tree? For example to hide menu when you click on main page content instead of menu you can: document.addEventListener(function (e) { var node = e.target; do { if (node.classList.contains('menu-area')) return; node = node.parentNode; } while (node instanceof HTMLElement); closeMenu(); }); Note that usual solution to hide menu when you click to non-menu area is event.stopPropagation() on menu and non-conditional document.addEventListener()