mootools

Change event on <select>

╄→гoц情女王★ 提交于 2019-12-05 00:56:46
With Mootools, if I attach a change event listener on a <select> how do I access the option that was selected. I would like the actual element and not just the value. $('select').addEvent('change',function(event) { //?? }); Either of these will work: find by :selected pseudo selector in descendants this.getElement(':selected'); get first selected value this.getSelected()[0]; pure javascript, use the selectedIndex property this.options[this.selectedIndex]; Just access the selectedIndex property on the select element ( this object in the event handler) to get the option index. // get the index

clone table row

≯℡__Kan透↙ 提交于 2019-12-04 23:39:07
问题 How can i use javascript (i assume) to clone a table row like ive beautifully illustrated in the picture below? 回答1: You can hookup a live event to all the buttons. If you give them a class of clone for instance the following will work. $('input.clone').live('click', function(){ //put jquery this context into a var var $btn = $(this); //use .closest() to navigate from the buttno to the closest row and clone it var $clonedRow = $btn.closest('tr').clone(); //append the cloned row to end of the

How do you grab an element from a remote page using MooTools and Request.HTML?

大憨熊 提交于 2019-12-04 20:11:35
I'm using MooTools ( part of the project ) to load a page using Request.HTML which works fine except that I don't want the whole page, just one fragment which has an id. This is the code in question var req = new Request.HTML({ onSuccess: function( res ) { // according to the docs // res should be the node list of the remote response // I want to grab #myFragment var f = res.getElementById('myFragment'); // res.getElementById is not a function var f = $(res).getElementById('myFragment'); // $(res) is null ? var f = $$(res).getElementById('myFragment'); // [null, null] ?? // more code } }).get(

Javascript Dynamic Grouping

此生再无相见时 提交于 2019-12-04 19:17:41
I am trying to create a table, with some grouping headers. All is well when i have 1 group, but how do i create dynamic groups? This is what i have so far (for 1 group): var groupby = ''; arrdata.each(function(element){ if (groupby != element.groupby) { groupby = element.groupby; tbody.push(groupby) } tbody.push(element) }) How do i make it create dynamic groups? You could group them into an Object first: Array.prototype.groupBy = function(keyName) { var res = {}; this.forEach(function(x) { var k = x[keyName]; var v = res[k]; if (!v) v = res[k] = []; v.push(x); }); return res; }; Then for ..

Jsonp with MooTools

廉价感情. 提交于 2019-12-04 18:40:00
I'm learning javascript and now I'm trying to work with mootools. I would like to work with json files in remote so I'm trying to use jsonp. Right now I have a textbox and when I click a button I would like to make a request of a json file. The url of the json file is something like www.mysite.com/json/sometext where sometext is the content of the textbox. The problem is that I don't really understand how the request and mootools work. Right now I don't have the code because I don't know how to start (I'm a beginner) but I would like to get the json file at http://m.airpim.com/json/public

Should I convert from MooTools to jQuery? [closed]

柔情痞子 提交于 2019-12-04 15:59:41
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I have a fairly large codebase that depends on MooTools v1.11 and am about to convert to version 1.2. Since this is a pretty major

How does jsfiddle mark up code? Is there a library for this?

a 夏天 提交于 2019-12-04 14:24:02
If you've ever used www.jsfiddle.net, you might notice that it marks up code with proper colorings, and various other helpers like translating tabs to four spaces or shift-tab. With Firebug I see that it's doing this with an iFrame. Is there an open source library to do this? I want to let people write Python on a web page, but make it pretty like jsfiddle. Check out CodeMirror . Look here (SyntaxHighlighter) Here you can find a simple tutorial . 来源: https://stackoverflow.com/questions/4301347/how-does-jsfiddle-mark-up-code-is-there-a-library-for-this

Ajax login form - browsers won't save password

大城市里の小女人 提交于 2019-12-04 13:12:31
I have Ajax login form, which is checking whether given credentials are correct and redirects to another page. The login form itself is built by a HXR call - it isn't built in the login page code. The problem is that I can't get browsers to prompt for remembering passwords. Once I've got the Firefox to prompt but since the form is being built by XHR call, the Firefox didn't paste the values into the form. PS. I am using mootools (Form.send) and usual window.location when login was successful. PSS. The address of the login page is always the same. The following code is loaded by a XHR within a

How far can you go with JavaScript testing?

旧城冷巷雨未停 提交于 2019-12-04 12:59:35
I'm somewhat informed with TDD and BDD with Ruby/Rails, but I will eventually need to use some form of testing with my JavaScript code. I use MooTools as a JS framework and I absolutely love how well I can organize and modularize my code with its codebase. But, sometimes, when I add new features to my application, I find that the functionality can easily break from how it worked before. When it comes to testing JavaScrtpt code, does the testing itself fall short of user interaction? Is it really only to test the ins and outs of method and (emulated) classes in JavaScript? Or is there a UX

How to detect when an element over another element in JavaScript?

送分小仙女□ 提交于 2019-12-04 07:33:23
I wrote most of the code... And when the element is "fully" over the other element it works. The problem is that I don't just want it to be true when the element is "fully" over the element, I also want it to be true when the element is partly over the other element. Here is my code: element = this.element.getStyles('left', 'top', 'width', 'height'); elementLeftX = element.left.toInt(); elementLeftY = element.top.toInt(); elementRightX = (element.width.toInt() + element.left.toInt()); elementRightY = (element.top.toInt() + element.height.toInt()); el = this.positions ? this.positions[i] : this