How to use the jquery.each function in jquery

To help you get started, we’ve selected a few jquery examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github talos / no.js / js / src / main.js View on Github external
.done(function (resp, status, doc) {
                    if (doc.responseText) {
                        var context = json.parse(doc.responseText);
                        $.each(templates, function (id, template) {
                            $app.find('#' + id).html(mustache.render(template, context));
                        });

                        // This is hacky, but have to make sure that
                        // chat is only updated if it is empty.
                        if ($chat.children().length === 0) {
                            $chat.html(mustache.render(chat, context));
                        }
                        id = context.id;
                    }
                    setTimeout(function () {
                        update(id);
                    }, 100);
                }).fail(function (resp) {
                    //console.log(resp);
github Kitware / candela / components / LineUp / index.js View on Github external
/* Always recreate the control */
    $(elem).empty();
    /* Lineup takes a d3 element */
    lineupObj = LineUpJS.create(spec.storage, d3.select(elem), this.lineUpConfig);
    lineupObj.restore(desc);
    config = lineupObj.config;
    lineupObj.header.dragHandler.on('dragend.lineupWidget', (evt) => {
      this.lineupDragColumnEnd(name, evt);
    });
    lineupObj['column-scale'] = scale;
    lineupObj['column-fixed'] = columnFixed;
    lineupObj['lineup-key'] = name;
    $(elem).attr('lineup-key', name);
    if (sort) {
      let sortColumn;
      $.each(lineupObj.data.getRankings(), function (ridx, ranking) {
        $.each(ranking.flatColumns, function (cidx, column) {
          if (column.label === sort) {
            sortColumn = column.id;
          }
        });
      });
      lineupObj.sortBy(sortColumn !== undefined ? sortColumn : sort);
    }
    lineupObj.changeRenderingOption('animation', oldAnimation);
    let fixTooltips = function () {
      for (var i = 0; i < desc.columns.length; i += 1) {
        if (desc.columns[i].description) {
          let label = (desc.columns[i].label || desc.columns[i].column);
          $('title', $(elem + ' .lu-header text.headerLabel:contains("' + label + '")').parent()).text(label + ': ' + desc.columns[i].description);
        }
      }
github openzipkin / zipkin / zipkin-ui / js / component_ui / trace.js View on Github external
$.each(selectedSpans, (i, $selected) => {
    $selected.show();
    $selected.addClass('highlight');
    $selected.expanded = true;
    $selected.$expander.html('<i class="far fa-minus-square"></i>');

    $.each(childIds[$selected.id], (j, cId) =&gt; {
      family.add(cId);
      spans[cId].openParents += 1;
    });
    $.each(parents[$selected.id], (j, pId) =&gt; {
      /* Parent may not be found for a number of reasons. For example, the
      trace id may not be a span id. Also, it is possible to lose the root
      span data (i.e. a headless trace) */
      if (spans[pId]) {
        family.add(pId);
        spans[pId].openChildren += 1;
      }
    });
  });
  family.forEach(id =&gt; spans[id].show());
github theatlantic / django-nested-admin / nested_admin / static / nested_admin / src / nested-admin / utils.js View on Github external
});
        });
        $.each(lookupFields.m2m || [], function(i, m2m) {
            $(form).djangoFormField(m2m).each(function() {
                var $this = $(this), id = $this.attr('id');
                // An autocomplete widget has already been initialized, return
                if ($('#' + id + '-autocomplete').length) {
                    return;
                }
                $this.grp_autocomplete_m2m({
                    lookup_url: lookupUrls.m2m,
                    autocomplete_lookup_url: lookupUrls.autocomplete
                });
            });
        });
        $.each(lookupFields.generic || [], function() {
            var [contentType, objectId] = this;
            $(form).djangoFormField(objectId).each(function() {
                var $this = $(this);
                var index = $this.djangoFormIndex();
                // An autocomplete widget has already been initialized, return
                if ($('#' + $this.attr('id') + '-autocomplete').length) {
                    return;
                }
                $this.grp_autocomplete_generic({
                    content_type: `#id_${prefix}-${index}-${contentType}`,
                    object_id: `#id_${prefix}-${index}-${objectId}`,
                    lookup_url: lookupUrls.related,
                    autocomplete_lookup_url: lookupUrls.m2m
                });
            });
        });
github mtth / avsc / js / index.js View on Github external
}
      if (typeof obj === 'number') {
        return  createDiv('-number-', obj + '');
      }
      if (typeof obj === 'boolean') {
        return createDiv('-boolean-', obj + '');
      }
      if (typeof obj === 'string') {
        // Calling json.stringify here to handle the fixed types.
        // I have no idea why just printing them doesn't work.
        return createDiv('-string-', JSON.stringify(obj));
      }
      var comma = false;
      if (obj instanceof Array) {
        res += '[<br>';
        $.each(obj, function(index, value) {
          if (comma) res += ',<br>';
          // Use '-' as a special character, which can not exist in schema keys 
          // but is a valid character for css class.
          res += createSpan(index , indent(depth) + stringify(value, depth + 1));
          comma = true;
        });
        res += '<br>' + indent(depth - 1) + ']';
        return res;
      } 
      res += '{<br>';
      comma = false;
      $.each(obj, function(key, value) {
        if (comma) res += ',<br>';
        res += createSpan(key, indent(depth) + '"' + key + '": ' + stringify(value, depth + 1));
        comma = true;
      });
github thecreation / jquery-asRange / dist / jquery-asRange.es.js View on Github external
constructor(element, options) {
    const metas = {};
    this.element = element;
    this.$element = $(element);

    if (this.$element.is('input')) {
      const value = this.$element.val();

      if (typeof value === 'string') {
        metas.value = value.split(',');
      }

      $.each(['min', 'max', 'step'], (index, key) =&gt; {
        const val = parseFloat(this.$element.attr(key));
        if (!isNaN(val)) {
          metas[key] = val;
        }
      });

      this.$element.css({
        display: 'none'
      });
      this.$wrap = $('<div></div>');
      this.$element.after(this.$wrap);
    } else {
      this.$wrap = this.$element;
    }

    this.options = $.extend({}, DEFAULTS, options, this.$element.data(), metas);
github audiotheme / audiotheme / admin / js / admin.js View on Github external
return this.each(function() {
			var repeater = $( this ),
				itemsParent = repeater.find( '.audiotheme-repeater-items' ),
				itemTemplate, template;

			if ( repeater.data( 'item-template-id' ) ) {
				template = wp.template( repeater.data( 'item-template-id' ) );

				if ( settings.items ) {
					repeater.audiothemeRepeater( 'clearList' );

					$.each( settings.items, function( i, item ) {
						itemsParent.append( template( item ).replace( /__i__/g, i ) );
					});
				}

				itemTemplate = template({});
				itemTemplate = $( itemTemplate.replace( /__i__/g, '0' ) );
			} else {
				itemTemplate = repeater.find( '.audiotheme-repeater-item:eq(0)' ).clone();
			}

			repeater.data( 'itemIndex', repeater.find( '.audiotheme-repeater-item' ).length || 0 );
			repeater.data( 'itemTemplate', itemTemplate );

			repeater.audiothemeRepeater( 'updateIndex' );

			itemsParent.sortable({
github 2600hz / monster-ui / apps / pbxs / app.js View on Github external
$('#empty_search', parent).hide();

				if (!searchString) {
					rows.show();
				}
				else {
					rows.hide();
					$.each(cache, function(phone_number, rowArray) {
						if (phone_number.indexOf(searchString)>-1) {
							matches.push(rowArray);
						}
					});

					if(matches.length > 0) {
						$.each(matches, function(k, v) {
							$(v).show();
						});
					}
					else {
						$('#empty_search', parent).show();
					}
				}
			});
		},
github tum-vision / autonavx_web / src / js / exercise7_visual_odometry.js View on Github external
'trajectory': function(time, trajectories) {
				if(trajectories['ardrone'] && trajectories['ardrone'].length > 0) {
					quadrotor_trajectory.push(trajectories['ardrone'][0]);
				}
				if(trajectories['kalman'] && trajectories['kalman'].length > 0) {
					kalman_trajectory.push(trajectories['kalman'][0]);
				}
				$.each(trajectories, function(name, points) {
					viewer.updateTrajectory(name, points);
				});
			},
			'points': function(time, point_data) {
github ExactTarget / fuelux / dist / all.js View on Github external
var rowHTML = '';

				self.$footerchildren.css('visibility', function () {
					return (data.count &gt; 0) ? 'visible' : 'hidden';
				});

				self.$pageinput.val(data.page);
				self.$pageslabel.text(data.pages);
				self.$countlabel.text(data.count + ' ' + itemdesc);
				self.$startlabel.text(data.start);
				self.$endlabel.text(data.end);

				self.updatePageDropdown(data);
				self.updatePageButtons(data);

				$.each(data.data, function (index, row) {
					rowHTML += '';
					$.each(self.columns, function (index, column) {
						rowHTML += '';
					});
					rowHTML += '';
				});

				if (!rowHTML) rowHTML = self.placeholderRowHTML(self.options.noDataFoundHTML);

				self.$tbody.html(rowHTML);
				self.stretchHeight();