How to use the jquery.when 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 OCA / web / web_widget_x2many_2d_matrix / static / src / js / web_widget_x2many_2d_matrix.js View on Github external
load_views: function() {
            // Needed for removing the initial empty tree view when the widget
            // is loaded
            var self = this,
                result = this._super();

            return $.when(result).then(function()
            {
                self.renderElement();
                self.compute_totals();
                self.$el.find('.edit').on(
                        'change', self.proxy(self.xy_value_change));
            });
        },
    });
github gsantiago / jquery-view / src / View.js View on Github external
var self = this
  this.$el = $el
  this.transclusion = $el.html()
  this._options = $.extend({}, View.defaults, options)
  this._data = {}

  $.each(this._options, function (key, option) {
    if (Object.keys(View.defaults).indexOf(key) !== -1) return
    self[key] = option
  })

  this.props = $.extend({}, this._options.props, utils.getProps($el))
  this._directiveEvents = []
  this._elementsWithEvents = []

  $.when(this._getTemplate(), this._getInitialData())
    .done(function (template, data) {
      $.extend(self._data, data)
      self._templateSource = template
      self._template = new Template(template)
      self.emit('template loaded')
      self._start()
    })
    .fail(function (err) {
      console.error(err)
    })
}
github tobernguyen / stop-scrolling-facebook / src / entry.js View on Github external
function tryToGetNewsfeed(cb) {
  $streamContainer = $(STEAM_CONTAINER_SELECTOR);
  let $newsFeedElement = null;

  let findNewsFeedContainer = $streamContainer.children().each(function() {
    if (NEWSFEED_STREAM_MATCHER.test(this.id)) {
      $newsFeedElement = $(this)
    }
  })

  $.when(findNewsFeedContainer).done(() => {
    return cb(null, $newsFeedElement)
  })
}
github viserjs / viserjs.github.io / pages / demo / examples / map / example1 / react.tsx View on Github external
componentDidMount() {
    $.when(
      $.getJSON('/assets/data/worldGeo.json'),
      $.getJSON('/assets/data/map-1.json')
    ).then((geoData, data) => {
      const dv = new DataSet.View().source(geoData[0], {
          type: 'GeoJSON'
      }).transform({
        type: 'geo.projection',
        projection: 'geoMercator',
        as: ['x', 'y', 'centroidX', 'centroidY'],
      });

      const userData = new DataSet.View().source(data[0]).transform({
        type: 'map',
        callback: (obj) => {
          const projectedCoord = dv.geoProjectPosition([obj.lng * 1, obj.lat * 1], 'geoMercator');
          obj.x = projectedCoord[0];
github WikiWatershed / model-my-watershed / src / mmw / js / src / analyze / models.js View on Github external
aoi = self.get('area_of_interest'),
            wkaoi = self.get('wkaoi'),
            result = self.get('result');

        if (aoi &&
            !result &&
            !utils.isWKAoIValid(wkaoi) &&
            self.runWorksheetPromise === undefined) {
            var taskHelper = {
                    contentType: 'application/json',
                    queryParams: null,
                    postData: JSON.stringify(aoi),
                },
                promises = self.start(taskHelper);

            self.runWorksheetPromise = $.when(promises.startPromise,
                                              promises.pollingPromise);

            self.runWorksheetPromise
                .always(function() {
                    delete self.runWorksheetPromise;
                });
        }

        return self.runWorksheetPromise || $.when();
    },
});
github gravitational / gravity / web / src / cluster / features / featureK8s.js View on Github external
onload({featureFlags}) {
    if (!featureFlags.siteK8s()) {
      this.setDisabled();
      return;
    }

    addSideNavItem({
      title: 'Kubernetes',
      Icon: Icons.Kubernetes,
      exact: false,
      to: cfg.getSiteK8sRoute(),
    })

    this.setProcessing();
    $.when(
      fetchDeployments(),
      fetchServices(),
      fetchNamespaces(),
      fetchPods(),
      fetchJobs(),
      fetchCfgMaps(),
      fetchDaemonSets())
      .done(() => this.setReady())
      .fail(this.setFailed.bind(this));
  }
}
github Netflix / genie / genie-ui / src / main / web / scripts / components / ApplicationDetails.js View on Github external
loadData(props) {
    const { row } = props;
    const applicationUrl = row._links.self.href;
    const commandsUrl = activeCommandUrl(row._links.commands.href);
    const allCommandsUrl = stripHateoasTemplateUrl(row._links.commands.href);

    $.when(fetch(applicationUrl), fetch(commandsUrl)).done(
      (application, commands) => {
        application[0]._links.commands.href = allCommandsUrl;
        this.setState({ application: application[0], commands: commands[0] });
      }
    );
  }
github misantronic / rbtv.youtube / app / components / comments / CommentForm.jsx View on Github external
this._submitXhr.then(data => {
                this.setState({
                    loading: false,
                    text: ''
                });

                $.when([
                    youtubeController.invalidateComments(`commentThreads.${this.context.videoId}`),
                    youtubeController.invalidateComments(`comments.${this.context.videoId}`)
                ]).done(() => {
                    if (this.props.onComment) {
                        this.props.onComment(data);
                    }
                });
            });
        });
github Kitware / candela / src / clique / adapter / Adapter.js View on Github external
let accs = neighborKeys.map((key, i) => {
          let acc = this.getAccessor(key);
          if (!acc) {
            return this.findNodeByKey(neighborKeys[i]);
          } else {
            return $.when(acc);
          }
        });