FAQ Database Discussion Community


Nested each statements aren't working

ruby,each
I'm trying to write a program in Ruby that finds the prime factors of a given number, without using Ruby's .Prime class. The code I wrote seems logical (if roundabout) to me, but for some reason the last line of code doesn't seem to work and I have no idea...

jquery each as 'named function'

javascript,jquery,function,each
I want to use this syntax var x = function() { //do something here } on an each function $("#firstname, #surname").each(function( index ) { if ($(this).val() == '') { errors += 1; } }); Is this possible, and what is this called (I called it 'named functions' is this right)?...

Trying to create a specific data-target for bootstrap modal through ruby iteration

ruby-on-rails,each,bootstrap-modal
I am using bootstrap modal on my rails project. On this page I have to iterate through my slides and for each slide I want to create a modal. I came up with this solution: <% @slides.each do |slide| %> <div class="row slidecard text-center"> <div class="col-xs-12 "> <h2><%= slide.name.upcase %></h2>...

comparing index values in an array

ruby-on-rails,ruby,indexing,each
I have an array that looks like this ranking_array = ['NC', '40', '30/5', '30/4', '30/3', '30/2', '30/1', '30', '15/5', '15/4', '15/3', '15/2', '15/1', '15', '5/6', '4/6', '3/6', '2/6', '1/6', '0', '-2/6', '-4/6', '-15', '-30'] I have also a model user, my user has a ranking which is a value that...

How do I conditionally use data when looping over an object

javascript,json,each
I'm trying to loop over a json structure and organize the images in different divs by the tags they have but I'm only able to spit out every single key value pair sequentially. Can I have some help? data = { -JkDpUSlAjzp0UMsVT-s: { image: "http://res.abc.png", color: "red", shape: "round" },...

JQuery loop on multiple items of the same CSS class

jquery,loops,each,keyup,word-count
I have multiple fields of the same class. The word count shows up correctly, but changes the value of every word count when one field has received input. Additionally, I'd expect the field to show a word count of 100 if no input exists, but it shows 0. Suggestions on...

Add each blocks date value as a class

jquery,each
Hello I would like to grab each date value just as string and add it as a class to article $('.alle-feesten'), what it does now is adding all values to every block so every block gets 3 extra classes. Every block should only get it's date so block1 gets value1,...

Assign .click() to multiple classes using .each()

jquery,each
I'm trying to assign event handlers to a bunch of classes that will be dynamically created at various points, and do so in an efficient way. I thought I could just create a list of key value pairs with the class as the key and the function as the value...

Create a variable of another variable (json, getJson method)

jquery,ajax,each,getjson
I have the following viable as an example: "ratioSize": "LP555/12317 Z ABCD" in my each function inside my getJson call: $.each(data.infoData, function (i, item) { // console.log(Rating); works just fine //console.log(stockNumber ); works just fine var Rating = this.tireRating; var stockNumber = this.SN; var ratioSize = this.TS var NEW_VARIALBE_I_NEED =...

Why does $.each show only one of my Mustache templates?

javascript,jquery,each,mustache
I'm using $.get inside $.each to call an external Mustache template to use on each Photo object in my array. Here is my code: $.when.apply($, requests).then(function(dataOne, dataTwo) { $.each(dataOne, function(idx, obj) { $.get("myTemplate.mst", function(template) { var rendered = Mustache.render(template, obj); $photoElem.html(rendered); }); }); }); My problem is that once I...

Why would my find method return undefined?

javascript,functional-programming,find,each
I'm recreating a number of Underscore.js methods to study JavaScript and programming in general. Below is my attempts to recreate Underscore's _.find() method. var find = function(list, predicate) { // Functional style _.each(list, function(elem){ if (predicate(elem)) { return elem; } }); }; var find = function(list, predicate) { // Explicit...

Running a function for each element

javascript,jquery,each
I am using the Peity js plugin to create donut charts on my page. I am trying to animate the chart for each of the .foo elements: <span class="foo" data-value="10"></span> $('.foo').each(function () { var updateChart = $(this).peity('donut'); var text = ""; var i = 0; function myLoop() { setTimeout(function ()...

How can I loop through string and replace all periods except the last one?

javascript,loops,replace,each
Let's say I have a string like this: var test = my.long.file.name.zip I am getting the total number of periods in this string with javascript like so: var dots = (test.match(/\./g) || []).length; I would then like to replace all of the periods in the string with underscores if there...

Sum values in jQuery object by key

jquery,each,jquery-csv
I have a csv file converted to a jQuery object using jQuery CSV (https://code.google.com/p/jquery-csv/). Here is the code for that: $.ajax({ type: "GET", url: "/path/myfile.csv", dataType: "text", success: function(data) { // once loaded, parse the file and split out into data objects // we are using jQuery CSV to do...

concatenate string from divs with the same class

javascript,html,loops,for-loop,each
I have the following code. function sendData(){ console.log($(".MultiFile-title").text()) } And the result from multiple titles is: file1.txtfile2.txtfile3.txt What I need is the output to be file1.txt, file2.txt, file3.txt I believe the a FOR EACH loop would be best here but how would I write it to get the text from...

jquery each loop through array with multiple objects

jquery,arrays,each,nested-loops,javascript-objects
I have a javascript array of multiple objects like the one bellow : var myArray = [{ year:'2015', model:'BMW', used:false, extras: [{buckets:'no',sportWheels:'yes'},{buckets:'no',sportWheels:'yes'}], color:'blue' ..... }]; What i am trying to do is to loop this array and pass the results into a list, something like this : $.each(myArray, function(i, e){...

Undefined method `each ' for an array containing a class instance

ruby,arrays,each
I'm trying to iterate over an array containing various instances of a class for a test case. An array should have an each function according to the RubyDoc: Like all classes that include the Enumerable module, Array has an each method, which defines what elements should be iterated over and...

How to break when found the item?

javascript,angularjs,promise,each,web-testing
I have a web test code and I don't want to iterate over the rest after i found the item. This code iterate to all item and the finally return. How to resolve this problem, because in the each I don't break! isItemPresent: function (name) { var def = Q.defer();...

applying a Function to Each element in an array (O'Reilly cookbook example)

arrays,function,each,element,apply
for nested data. I tried <?php $names = array('firstnames' => array("Baba", "Billy"), 'lastnames' => array("O'Riley", "O'Reilly")); array_walk_recursive($names, function (&value, $key) { $value = htmlentities($value, ENT_QOUTES); }) foreach ($names as $nametypes) { foreach ($nametypes as $name) { print "$name\n"; } } ?> (An example from the book O'reilly PHP Cookbook 3rd...

How do I perform an 'if' statement within a nested sass map (SCSS)?

css,if-statement,sass,each
As I'm new to sass (SCSS) it would appear that my ambition currently outstrips my abilities. Could someone assist me with the following task. BACKGROUND We currently have an icon system with two distinct file formats; one is a PNG and the other an SVG. Some of our icons have...

Rails undefined method `each' for nil:NilClass…but it is defined

ruby-on-rails,each
I have searched for hours, tried every possible fix. I cannot make this work. The error is: *NoMethodError in Articles#index Showing /Users/myname/blog/app/views/articles/showall.html.erb where line #21 raised: undefined method `each' for nil:NilClass* showall.html.erb is a view. It is rendered from the 'article' controller. (both posted below). There is a route to...

undefined method `each' for nil:NilClass when calling from another controller

methods,controller,undefined,each
I'm trying to trigger all the posts in a groups/show view, but I'm getting error "undefined method `each' for nil:NilClass". Anyone could help me, please? ~~sorry for my bad coding behaviors posts_controller: class PostsController < ApplicationController def index @posts = Post.all end def show @post = Post.find(params[:id]) end def new...

Jquery, using $.each, doesn't get the value of variable

jquery,select,add,each,options
I'm using Jquery to add some options to a select, but, the options are not always the same, so, I use a variable called materia to get the value of a previus select to know which options I should add. I dont know if Im explaining correctly, here's some code....

Using async.js with node.js

node.js,asynchronous,each,series,async.js
Visit.js - Notice that folloup.id refer to 0 or "n" Visits (like tree) var visitSchema = new Schema({ code : {type: String, trim: true, required: false, default: ""}, Client : { id: {type: Schema.Types.ObjectId, ref: 'Client'}, }, attendant : [{ name : {type: String, trim: true, required: false, default: ""},...

Need to access all the label values of an input and then truncate after the second underscore

jquery,each
i have a page where the markup looks something like this. i’m trying to use jQuery’s each. function to access the value of each label and then truncate after the second underscore. so for example, this value "M_1010_Lilac" would be changed to this value “Lilac” <div class="threads-swatch-wrapper"><input type="hidden" name="descriptive[51]" value="M_1010_Coral_Cloud"...

find() for multiple results

javascript,jquery,each
I'm using find as that in order to select inner $(".pauseAnomaly[data-id=78]").parent().parent().prev().find(".pauseaction").each(function (i) { pauseActionUI($(this).data("id")); }); I want to launch .pauseAction on each .pauseAction found in $(".pauseAnomaly[data-id=78]").parent().parent().prev(). Here, it works perfect when there is single .pauseaction but nothing when there is multiple .pauseaction, why? and how resolve this? In other words...

Jquery - How to put the id of each DIV.section as Anchor # on in Each li> a href?

jquery,text,each,attr
I am trying to get ID from .section divs and put in sequence for each li > a as href anchor '#', and get value text from .section > h3 put in li > a corresponding to .section ID. HTML (rendered): <div id="tabs_wrap"> <ul> 'Js render list here' </ul> </div>...

Play the videos using jquery loops

javascript,php,jquery,each
I have an array of video urls. I passed the urls from php to jquery using json. The script is like this $('.cnt_lsn').click(function(e){ e.preventDefault(); var video_dets = JSON.parse($(this).attr('data-video-det')); $.each(video_dets, function(i, v){ console.log(i); console.log(v.vid_url); }); }); So the value is coming like 0 TW51XsixMqA 1 LxRiFFEXs5I Now how can i make...

Nested jQuery each statement runs after the first has completed

javascript,jquery,html,each
I want to dynamically create a combo box by reading a JSON variable. The problem is that the first $.each() statement always finishes before the second $.each() statement. This makes the two options fall outside of the <select> element. What am I doing wrong? var oFields = { "fields": [...

Confused about the jQuery $.each function

javascript,jquery,function,each
Let's say I have $.each(data,function(i,item){ ... }); I get that $.each is going to iterate over the object (or array) data but I am confused about the function. Why is "i" incrementing by 1 ("i"++) over the loop and what defines "item" to be data[i]? Is this just a built...

How to add a class to an element if all elements have a given class?

jquery,each,addclass
I have several div having class .toCheck. By clicking to one of these divs, I'm adding to the clicked div the class .readyToSend I also have a button "#send", and every time I'm clicking a .toCheck div, if all the .toCheck divs have the class .readyToSend I want to add...

Jquery - Loop each Selected Option

jquery,local-storage,each
I have a very simple form that contains a select dropdown list. <select name ='select[]' id='select' class='select'> <option value=1>1</option> <option value=2>2</option> <option value=3>2</option> </select> Using Jquery I have a button that when clicked clones this select and removes the ID. $('#add').click(function() { var $new = $('#row').clone(true).removeAttr('id'); $new.find('*').andSelf().removeAttr('id'); $('#tbl_test tr:last').before($new); return...

Create array using _.each

javascript,arrays,functional-programming,underscore.js,each
I've this exercise to solve: Use _.each to create an array from 1, 1000 (inclusive) I really don't know how to do that and i'm thinking it's not possible... Can you help me?...

Push to 2D Arrays in Javascript

javascript,jquery,arrays,multidimensional-array,each
I am trying to understand how 2D Arrays should work in Javascript, where I am currently attempting to store data in categories. In this scenario, I have a list of maps such as... arena_badlands arena_dust ctf_2fort cp_dustbowl I would like to create a 2D Array where they are categorized by...

jQuery: How to set different action for each loop only for first row of table

javascript,jquery,loops,each
I am new to jQuery and hope someone can help me with this. I have a large, dynamically created table that contains 3 columns, one for amounts that need to be subtracted, one for amounts that need to be added and one for the sum of each row. So far...

jQuery Error: Syntax error, unrecognized expression: [object HTMLDivElement]

javascript,jquery,each
I am looping through a set of elements and then I am trying to find some specific children of said element in the loop at that time, but I am getting an error. My code: var submenu_height; var secondary_submenus; var secondary_submenu_height; // Get the submenus var submenus = $('#main section.top...

Handlebars - How to access template data in “each” scope?

javascript,handlebars.js,each
I use pre-compiled Handlebars templates. I have the following code: <div id="{{ns}}paymentMethodsTabs"> {{#each paymentMethods}} <button id="{{ns}}{{paymentCardCode}}">{{paymentCardCode}}</button> {{/each}} </div> In the first div, the ns template data is available and set. But inside the each paymentMethods scope, I can't access it, I tried <button id="{{../ns}}{{paymentCardCode}}">{{paymentCardCode}}</button> But it doesn't work either. (the...

hover animation on each element but not on the hovered element

jquery,hover,each
I have a very classic menu : when we click on a menu bttn, a text will appear nearby... The structure : <ul id="menu"> <li class="menu-point"> <span class="menu-text"></span> <a class="menu-bttn"></a> </li> <li class="menu-point"> <span class="menu-text"></span> <a class="menu-bttn"></a> </li> <li class="menu-point"> <span class="menu-text"></span> <a class="menu-bttn"></a> </li> </ul> I do not know...

Find last but one element in #each helper in ember

ember.js,handlebars.js,each
In my ember application I've a scenario where I want to display the last but one element of an array in a different way. {{#each item in model}} {{#if lastButOneItem}} + {{item}} {{else}} {{item}} + {{/if}} {{/each}} But I'm not sure how to put the condition for the lastButOneItem. Is...

jQuery multiple class and nth-child

javascript,jquery,each
I have a table which has multiple classes. <tr> <td class='one two'>One</td> <td class='one three'>Another</td> <td class='one example'>Yet another</td> <td class='one two'>Yet another</td> <td class='four'>Four</td> </tr> <tr> <td class='one two'>One</td> <td class='one three'>Another</td> <td class='one example'>Yet another</td> <td class='one two'>Yet another</td> <td class='four'>Four</td>...

jQuery loop through .hover( ) function using .each( )

javascript,jquery,arrays,each
I have a function that changes the border-color of the arrows to match the hover state colour of the buttons. It is working as 3 separate functions but I want to combine them using .each( ) Please tell me where I am going wrong Vars var btnArrowPath = '.btn +...

Call function after $.each method

jquery,arrays,asynchronous,each
I'm using the $.each method on an array to save files to local folder. How can I perform a function once the .each method has finished with last file in array? .done method not working. function downloadStartData() { $.each(startUpimageFilesArray, function (index, entry) { saveTofolder(entry.addy, entry.nameOfFile) }); }; function saveTofolder(url, fileName)...

trying to use each method to find divisible numbers and print them

ruby,each
I'm new to ruby and new to stack. I am trying to use the .each method on an array of numbers to see which numbers are divisible by 4, and 400. It is based on an exercises from Chris Pine's "Learn to Program" Ruby tutorial. In it you are supposed...

Javascript loop create Object [closed]

javascript,object,each
i want to create an object but it doesn't work so far. var optionz = []; $('ul > li > a').each(function( index ) { optionz [ $(this).attr('href') ] = $(this).children('img').attr('src'); // alert($(this).attr('href')+ " " +$(this).children('img').attr('src')); }); $.each(optionz, function (index, value) { alert( index + ' : ' + value );...

Count data per day in a specific month in Postgresql

postgresql,count,each
I have a table with a create date called created_at and a delete date called delete_at for each record. If the record was deleted, the field save that date; it's a logic delete. I need to count the active records in a specific month. To understand what is an active...

How is `each` different from `for-loop` when returning a value?

javascript,functional-programming,find,each
I have my each function which I created to emulate Underscore.js's _each() for my Javascript study. var each = function(list, iteratee) { if (Array.isArray(list)) { // list is array for (var i = 0; i < list.length; i++) { iteratee(list[i], i, list); } } else if (list.constructor === Object) {...

How do I remove a dynamically added element after 5 seconds?

javascript,jquery,each,settimeout
I'm making a simple game where users should click flies to remove them from the screen. The user should not click the cat when it drops, and I'm hoping to make the cat gif disappear (remove itself from the DOM) after 5 seconds. I apologize if this has been answered...

Get position of each element

javascript,jquery,each,offset
$(function(){ var $animatedEls = $(".marked"); $(window).scroll(function(e) { var offset = 0; $.each($animatedEls, function(i, item) { offset = $(item).offset().top; console.log($(item).offset()); }); }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <h2 class="marked">This sucks.</h2> <div>...</div> <h2 class="marked">This sucks.</h2> <div>...</div> <h2 class="marked">This sucks.</h2> <div>...</div>...

Adding a list of data to object inisde loop

jquery,object,each
I have been attempting to add a list of values into a object/associative array so i can get a list of values from the input of a multiselect plugin. Im wanting to add the name of the input as the object key. Problem: Doesnt seem to create a list, just...

Ruby .each method on Array from split string

arrays,ruby,while-loop,split,each
I'm having trouble using the .each method on an array that results of a string.split def my_function(str) words = str.split return words #=> good, morning return words[words.count-1] #=> morning words.each do |word| return word end end puts my_function("good morning") #=> good With any multi-word string, I only get the 1st...

Pig Latin exercise works, but only for one user inputed word. Not all words

ruby,arrays,each
I'm new to programming and I'm working with Ruby as my starter language. The below code works, but if someone inputs more than one word, the pigatize method only works on the first word and adds the additional ay or way to the last word. How do i get it...

How to do something different with first element in each loop?

jquery,each
Within an each() loop, is it possible to do something with the first element in particular, not the next ones? Something like this: $( '.selector').each(function(){ // if first element found, do something }); ...

For each li in list that contains span with text, remove another span from within that li

javascript,jquery,each
I have a list of items. In each list item, I have spans. I want to check if one span contains a string (in this case is : "Account"), to remove another span from that List item only. I am selecting the items by Class, not by Id. I tried...

Set data attribute in jquery each loop [duplicate]

jquery,each
This question already has an answer here: How to set data attribute with jQuery on element that is not in DOM yet? 3 answers I have a simple page: <div>test 1</div> <div>test 2</div> <div>test 3</div> <div>test 4</div> <div>test 5</div> the jQuery script: $( document ).ready(function() { $.each($('div'), function (index,...

Using $(this) at a method inside another method in jQuery

javascript,jquery,this,each,selector
So, I'm trying to use the 'this' selector in a method inside another method, example: $('form').submit(function(event){ $('input').each(function(){ if($(this).val().length < 2){ $(this).addClass('error'); event.preventDefault(); } }); }); When I made that, I thought it would admit 'this' as each input, but no, the 'this' selector are associated to the form. I know...

Am I using the jQuery .each function incorrectly?

javascript,jquery,ajax,json,each
I am using some jQuery to retrieve and parse some JSON from a third party website, so I can use images from that site to populate a gallery. Please see the details below, and reproduced in this JSFiddle: $(document).ready(function() { function populateImages(path) { $('.crush').each(function() { $(this).html('<img src="' + path +...

jQuery $.each for specific keys within an array of objects

jquery,object,each
I have this array of objects below and i want to iterate with $.each and get the type and description Object[ Object { advert_id=7, type="entipo", description="magazine" }, Object { advert_id=8, type="tv", description="commercials" } ] ...

Build 2 level javascript array inside loop

javascript,arrays,loops,each
I dont know if the title is wrong... i dont know which term i should use to exaplain the desired result - the end result i am trying to achieve is this: var data = [ { value: 300, color:"#F7464A", highlight: "#FF5A5E", label: "Red" }, { value: 50, color: "#46BFBD",...

Having Trouble with jQuery Function using .each()

javascript,jquery,twitter-bootstrap,for-loop,each
I have a navigation that is made up of Bootstrap dropdowns. Within each dropdown there are 15-20 list-items being generated. I do not have access to the HTML because it's being generated dynamically in a place I can't touch. Due to the number of list-items, I have a requirement to...

Assigning variables?

for-loop,each,office-2010
I have looked for awhile to find the answer, I see some similar codes and try to adjust my code to work. Basically, I need all textboxes on my userform to turn red with white font based on the text received from another work sheet in one of the textboxes....

Ajax wait on success before next iteration in .each loop

ajax,each
I have an ajax call inside a .each loop wrapped in a setInterval function. This handles updating of many divs on a dashboard with just a few lines of code on the html page. I am worried about server lag vs client side speed. What will happen if the server...

jquery .each loop odd behaviour

javascript,jquery,each
Hi I have the following code html <table id="tbPermission"> <tr> <th>User ID</th> <th>User Name</th> </tr> <tr> <td>1</td> <td>Test1</td> </tr> <tr> <td>2</td> <td>Test2</td> </tr> <tr> <td>3</td> <td>Test3</td> </tr> </table> script var trArray = []; var tdArray = []; var reruiredObj = {"UserID":null, "UserName":null }; var first; var second; $('#tbPermission tr').each(function ()...

Nested json, and recursive $.Each()

jquery,json,recursion,nested,each
I've got a nested JSON like this : [{ "1": { "name": "Mobile" }, "5": { "name": "Savings", "childs": { "27": { "name": "Children" } } }, "6": { "name": "Pro Expenses" }, "7": { "name": "Salary", "childs": { "143": { "name": "Salary Savings" } } }, "8": { "name":...

Loop through list of AWS-instances shows only first item

ruby-on-rails,amazon-web-services,amazon-ec2,each,aws-sdk
I am working on a simple customer frontend for AWS. I want a list of all the users machines for start/stopping the EC2s. While the logic works I can only show the first of the machines in my view. I guess it's related to the AWS APIs pageable response format,...

How to execute a function after Jquery callbacks inside .each loop have comepleted

javascript,jquery,callback,devexpress,each
I have a function that calls JQuery.each(). It then calls a third party function,(Devexpress GetRowValues()), that executes a callback. After the .each has finished, I have to call DoSuccess() and pass in the array rv. The problem is that RVGridCB() executes after DoSuccess(). How can I ensure that all callbacks...

How does each function and this keyword work together in d3?[chaining transitions]

javascript,d3.js,this,each
I'm using the d3 library and having a hard time wrapping my head around some of the constructs, hoping for some guidance from experienced hands with this! <!DOCTYPE html> <html lang="en"> <head> <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> </head> <body> <script> var svg=d3.select("body").append("svg").attr("width",800).attr("height",1000); svg.selectAll("circle") .data(d3.range(10)).enter().append("circle") .attr("cx",function(d){return d;})...

JQuery forEach function works only one way

jquery,tabs,each
I am creating my own tabbing function for jumping from one div to another based on user selection. Basically it's very similar to JQueryUI's Tabs. The only problem I have is with the "next" and "prev" buttons - I wrote a function that changes the variable classes based on arguments...

Jquery equation for each table row

jquery,table,row,each
I'm having a bit of trouble with the code below and I'm too new to jQuery to figure it out. function calcExpiration(){ var getState = jQuery( "#state" ).text(); var getcalldate = jQuery( "#date" ).text(); var date = new Date( getcalldate ); if (getState == "KY" || getState == "IN"){ date.setDate(date.getDate()...

Jquery: Adding css class to certain divs based on attributes

javascript,jquery,css,each
I have several divs that all have the an attribute called number. <div class="foo" number="1"></div> <div class="foo" number="2"></div> <div class="foo" number="3"></div> ...and so on. When I click on one of them, I catch the number and store it in a variable. I then want to run a function that adds...

$.ajax inside $.each blocking browser

javascript,jquery,ajax,each
I have something like this: loop through the ids and for each one, make an ajax request (async:true) to the server (same domain) and append received data to a DOM element. Not a hard task to accomplish, it works. Example code: $.each(ids, function (index, id) { $.ajax({ type: 'POST', url:...

Ruby on Rails - Why can't I use ActiveRecord::Base methods? Where to use?

ruby-on-rails,ruby-on-rails-4,rails-activerecord,each,collect
I've been trying to use ActiveRecord::Base methods such as .each and .collect in my application but I keep getting undefined method errors! Perhaps I have a shaky knowledge of Ruby. It seems like I can't use these methods in my controller, methods or views? For example, the code below will...

each() function skips in JQuery and does nothing on arrays

javascript,jquery,arrays,foreach,each
I wrote this code to iterate of each element of Reshte array but it skips all and it's contents never runs Reshte = $('.seeker_register select[name="Reshte[]"]').toArray(); Gerayesh = $('.seeker_register select[name="Gerayesh[]"]').toArray(); Moadel = $('.seeker_register select[name="Moadel[]"]').toArray(); // Reshte.each(function(index, el) { Reshte.each(function(index, el) { if ($(Reshte[index].val() )){ review_page += 'Diplom: '+ $(Reshte[index]).val()+ ' '+...

Using Each to loop thru hashes (1 vs More)

ruby-on-rails,hash,each
I have a hash that is being parsed out and sent into my function. The issue i am having is that when i send in 1 post it errors out because it parses out each attribute and sends each attribute as a post. If I send more then 1 post,...

Stopping propagation on multiple hover event

javascript,jquery,javascript-events,each,preventdefault
My home page contains multiple boxes. On each boxes, when mouseover in or out , the title disappears and the content appears. It works fine. The problem is that when mouseovering more than one box on a short period of time, it is a mess. $( ".views-field-wrapper" ).each(function(){ $( this...

jquery each loop return false not end the function

jquery,each
I have a function which get a dot seperated string and parse it to array. And I want to loop these array elements and check a value is greater than 255 and return false, if not continue to function statements and return true as end of function. But it never...

Jquery count total values in an each loop

jquery,count,each
Trying to count each value from a checked input. Independently the code works and returns each value - I need to add them all together outside of the each loop so that I can interrogate the value. Code is: // Declare empty count quiz_count = 0; $('.questions li ul li').each(function(checking){...

JQuery - delay and show text issue

javascript,jquery,each,delay,settimeout
below i got some code, which should delay 2 seconds and hide previous span and show the next span, but i cant seem to get it to work. <style> span{ display:none} </style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"><script> <div id="text"></div> <script> var text = [ "<span>Sent A blabla</span>", "<span>sent B</span><span>sent b bbb cont....</span>", "<span>Sent...

Trying to insert into websql table from Json, using each()

jquery,json,cordova,web-sql,each
I'm currently working on a phonegap app, wich must sync with a distant mysql server. I load a json file using getJson() and insert the rows into a websql database. My problems is that only the first row is inserted in the websql DB. I actally got two rows in...

jQuery for each div class find child and insertAfter

javascript,jquery,html,each,children
I am editing my blog theme and I need to move (cut and paste) multiple specific divs under itself within a specific blog post. The current HTML would be <div class="blog_post text_post"> <div class="post_container"> <div class="bottom_meta"></div> <div class="post_date"></div> <div class="moreinfo"></div> <!-- I need .bottom_meta here --> </div> </div> I managed...

using .each to loop through Json Response

jquery,json,each
I'm trying to loop through a json object with .each(), but I'm struggling with getting the syntax right. Ajax Call, which results in "undefined": $('.showGroup a').on('click', function(e) { e.preventDefault(); var _href = $(this).attr("href"); $.ajax({ dataType: 'json', url : _href, type : 'GET', success : function(response) { $("#replace").empty(); display = response;...

How to get the index of each element using jQuery each function

jquery,events,each
I'm making an menu and for that I use jquery to display data. I want to make it more dynamic and for that I'm using the each() function Here is an representative example of my code http://jsfiddle.net/4r5cLy00/ As you can see the on click displays all the listitems of the...

Unexpected array output on page

ruby-on-rails,arrays,ruby-on-rails-4,select,each
I'm listing a set of data (for simplicity sake, just the identity column) of a particular database table table as follows: <%= @fields.select{|field| field.model=="PreferredOffering"}.each do |field| %> <%= field.id %> <br/> <% end %> As you may have gathered from above, I'm using the combination of select and each to...

Adding map markers from object using $.each doesn't work

json,google-maps-api-3,google-maps-markers,each
Here is my code. If I use loadGeoJson it shows the markers. If I use $.getJSON to load the data to an object and step through it adding each marker, I don't see any markers. I do see all the names show up in the "pList" div so I know...

JQUERY each returns data twice =(

jquery,jquery-animate,each
Please, play with teh fiddle below. ONE bug goes as it should - turns its "head" and crawls in proper direction. But several bugs (starting with two and up) destroy it all. Jquery "each" returns coordinates twice so instead of two sets of coordinates for two bugs FOUR are generated....

When using an $.each statement on my json object I get an error

javascript,json,each
When using an $.each statement on my json object I get an 'Uncaught TypeError: Cannot read property 'length' of undefined'. I know my $.each statement is causing it because when I comment it out the console.log returns [Object, Object, Object] as expected. What I'm trying to do is iterate through...

Variable as field name jquery validate rules

jquery,regex,jquery-validate,each
I'm currently using the jquery validate rules plugin and I'm running into the following issue. While some of my input fields have static IDs. There are some fields that are dynamically generated so the ID isn't static. Unfortunately I don't have control of the ID generated. I can use a...

Refactoring jQuery each loop on data object

jquery,object,refactoring,each
I have a csv file converted to a jQuery object using jQuery CSV (https://code.google.com/p/jquery-csv/). Here is the code for that: $.ajax({ type: "GET", url: "/path/myfile.csv", dataType: "text", success: function(data) { // once loaded, parse the file and split out into data objects // we are using jQuery CSV to do...

jQuery - Add class to each span that uses more than one line

jquery,arrays,each,parent
I got a little bit stuck on this piece of code, so I hope you can help me and this question can help others :) What I want to accomplish is adding a class to a parent().parent() (I don't know how to call it in english) of a span that...

Get return from javascript anonymous funcion in each loop(s)

javascript,jquery,loops,each
I've never worked with js before and now faced with a problem, how can I do next? function test() { $(xml).find("strengths").each(function() { $(this).each(function() { (if some condition) { //I want to break out from both each loops at the same time here. // And from main function too! } });...

Pulling JSON data from external file with ajax

jquery,ajax,json,datatables,each
I am currently pulling in JSON manually to test with a bootstrap table, but need to be able to pull from an external file, similar to how I was doing here: $(document).ready(function() { $('#content').dataTable( { "ajax": 'test.log' }); }); I'm currently manually setting data and looping through it like so:...

Each HTML div Requires item

jquery,match,each
<div><input type="text" name="">{name}</div> <div><input type="radio" name="{demo}" value="{yes}"></div> <div><input type="radio" name="{demo}" value="{no}"></div> $.each($('div'),function(k,v){ var s = $(v).html(); console.log( s.match(/{(.*)}/gi) ); }); I am trying to parse out all of the items wrapped in {curly braces}. I expect to see the following result: ['{name}', '{demo}', '{yes}', '{no}'] But when I run the...

Grails Sending parameter from g:each to javascript

javascript,json,grails,each,gsp
What I need to do is show more information than the table size allow me to show. For that, I'm opening a jQuery Dialog with the whole information when the user mouse over the row he needs to see. The problem I have is when I pass the parameter from...