How to use the jquery.Deferred 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 cwrc / CWRC-WriterBase / src / js / conversion / xml2cwrc.js View on Github external
function buildDocumentAndInsertEntities(doc) {
        var dfd = new $.Deferred();

        buildEditorStringDeferred(doc.documentElement)
        .then(function(editorString) {
            w.editor.setContent(editorString, {format: 'raw'}); // format is raw to prevent html parser and serializer from messing up whitespace

            return insertEntities();
        })
        .then(function() {
            w.tagger.addNoteWrappersForEntities();

            if (w.entitiesManager.doEntitiesOverlap()) {
                w.allowOverlap = true;
            } else {
                w.allowOverlap = false;
            }
github OpenDroneMap / WebODM / app / static / app / js / components / EditTaskForm.jsx View on Github external
return $.ajax({
        url: `/api/presets/${selectedPreset.id}/`,
        contentType: 'application/json',
        type: 'DELETE'
      }).done(() => {
        presets.splice(presets.indexOf(selectedPreset), 1);

        // Select first by default
        this.setState({presets, selectedPreset: presets[0], editingPreset: false});
      }).fail(() => {
        this.setState({presetError: "Could not delete the preset. Please try to refresh the page."});
      }).always(() => {
        this.setState({presetActionPerforming: false});
      });
    }else{
      return $.Deferred().resolve();
    }
  }
github cloudera / hue / desktop / core / src / desktop / js / apps / table_browser / metastoreViewModel.js View on Github external
}
    if (pathParts[0] === 'metastore') {
      pathParts.shift();
    }
    const loadedDeferred = $.Deferred();

    if (!this.loading()) {
      loadedDeferred.resolve();
    } else {
      const loadSub = this.loading.subscribe(() => {
        loadSub.dispose();
        loadedDeferred.resolve();
      });
    }

    const sourceAndNamespaceDeferred = $.Deferred();

    loadedDeferred.done(() => {
      let search = location.search;
      let namespaceId;
      let sourceType;
      if (search) {
        search = search.replace('?', '');
        search.split('&').forEach(param => {
          if (param.indexOf('namespace=') === 0) {
            namespaceId = param.replace('namespace=', '');
          }
          if (param.indexOf('source_type=') === 0) {
            sourceType = param.replace('source_type=', '');
          }
        });
      }
github DigitalSlideArchive / HistomicsTK / web_client / dialogs / openImage.js View on Github external
validate: function (item) {
            if (!item.has('largeImage')) {
                return $.Deferred().reject('Please select a "large image" item.').promise();
            }
            return $.Deferred().resolve().promise();
        }
    });
github cloudera / hue / desktop / core / src / desktop / js / ko / components / assist / ko.assistEditorContextPanel.js View on Github external
activeLocations.activeStatementLocations.forEach(location => {
          if (
            location.type === 'table' &&
            (location.identifierChain.length !== 1 ||
              !ctes[location.identifierChain[0].name.toLowerCase()])
          ) {
            const tableDeferred = $.Deferred();
            const dbDeferred = $.Deferred();
            runningPromises.push(tableDeferred);
            runningPromises.push(dbDeferred);

            const qid = createQualifiedIdentifier(
              location.identifierChain,
              activeLocations.defaultDatabase
            );
            if (activeTableIndex[qid]) {
              tableQidIndex[qid] = true;
              tableDeferred.resolve(activeTableIndex[qid]);
              dbDeferred.resolve(activeTableIndex[qid].parent);
            } else {
              let database =
                location.identifierChain.length === 2
                  ? location.identifierChain[0].name
                  : activeLocations.defaultDatabase;
github uploadcare / uploadcare-widget / src / files / group.js View on Github external
__initApiDeferred() {
    var notify, reject, resolve
    this.__apiDf = $.Deferred()
    this.__progressState = 'uploading'
    reject = err => {
      return this.__buildInfo(info => {
        return this.__apiDf.reject(err, info)
      })
    }
    resolve = info => {
      return this.__apiDf.resolve(info)
    }
    notify = () => {
      return this.__apiDf.notify(this.__progressInfo())
    }
    notify()
    this.__fileColl.onAnyProgress(notify)
    this.__allFilesDf
      .done(() => {
github cloudera / hue / desktop / core / src / desktop / js / catalog / dataCatalogEntry.js View on Github external
deleteNavigatorTags(tags) {
    const self = this;
    const deferred = $.Deferred();
    if (self.canHaveNavigatorMetadata()) {
      self
        .getNavigatorMeta()
        .done(navMeta => {
          if (navMeta && typeof navMeta.identity !== 'undefined') {
            apiHelper
              .deleteNavTags(navMeta.identity, tags)
              .done(entity => {
                if (entity) {
                  self.navigatorMeta = entity;
                  self.navigatorMetaPromise = $.Deferred()
                    .resolve(self.navigatorMeta)
                    .promise();
                  self.saveLater();
                } else {
                  deferred.reject();
github gocd / gocd / server / webapp / WEB-INF / rails / webpack / helpers / ajax_helper.js View on Github external
function makeRequest({method, url, apiVersion, type, timeout = mrequest.timeout, payload, etag, contentType = false} = {}) {
  return $.Deferred(function () {
    const deferred = this;

    const jqXHR = $.ajax({
      method,
      url,
      data:       JSON.stringify(payload),
      timeout,
      beforeSend: (xhr) => {
        xhr.setRequestHeader("GET" === method.toUpperCase() ? 'If-None-Match' : 'If-Match', etag);
        mrequest.xhrConfig.forVersion(apiVersion)(xhr);
      },
      contentType
    });

    const didFulfill = (data, _textStatus, jqXHR) => {
      const NOT_MODIFIED = 304 === jqXHR.status;
github OpenBazaar / openbazaar-desktop / js / views / modals / listingDetail / Listing.js View on Github external
get purchaseModal() {
    this._purchaseModalDeferred =
      this._purchaseModalDeferred || $.Deferred();

    if (this._purchaseModal) {
      this._purchaseModalDeferred.notify({
        type: this.constructor.PURCHASE_MODAL_CREATE,
        view: this._purchaseModal,
      });
    }

    return this._purchaseModalDeferred.promise();
  }
github cloudera / hue / desktop / core / src / desktop / js / api / apiHelper.js View on Github external
createGist(options) {
    const self = this;
    const deferred = $.Deferred();

    const request = self.simplePost(
      GIST_API + 'create',
      {
        statement: options.statement,
        doc_type: options.doc_type,
        name: options.name,
        description: options.description
      },
      {
        silenceErrors: options.silenceErrors,
        successCallback: deferred.resolve,
        errorCallback: deferred.reject
      }
    );