How to use the jquery.proxy 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 LocalData / localdata-dashboard / src / js / views / builder.js View on Github external
$question = $(this.templates.textQuestion({question: question}));
      }
      if(question.type === 'counter') {
        $question = $(this.templates.counterQuestion({question: question}));
      }

      // Listen for changes to the question ...................................
      // TODO: make it less verbose

      // Listen for changes to the question text
      var editQuestionProxy = $.proxy(this.editQuestionFactory(question), this);
      $question.find('> div input').keyup(editQuestionProxy);

      // Listen for a request to remove a question
      // TODO: confirm delete
      var deleteQuestionProxy = $.proxy(this.deleteQuestion($question, parent, questionIndex), this);
      $question.find('> div .remove').click(deleteQuestionProxy);


      // Listen for a request to add a question
      var createQuestionProxy = $.proxy(this.createQuestionFactory(parent, questionIndex), this);
      $question.find('.add-sub-question').click(createQuestionProxy);

      // // Add a sub-question
      // var $addSubQuestion = $answer.find('.add-sub-question');
      // var addSubQuestionProxy = $.proxy(this.addSubQuestionFactory(question, index), this);
      // $addSubQuestion.click(addSubQuestionProxy);

      // // Listen for a request to add a photo question
      // var createPhotoQuestionProxy = $.proxy(this.createPhotoQuestion(parent, questionIndex), this);
      // $question.find('.add-photo-question').click(createPhotoQuestionProxy);
github cwrc / CWRC-WriterBase / src / js / dialogs / attributeWidget / attributeWidget.js View on Github external
this.isDirty = false;
    
    this.$el.addClass('attributeWidget');
    this.$el.append(''+
    '<div class="attributeSelector">'+
        '<h2>Attributes</h2>'+
        '<ul></ul>'+
    '</div>'+
    '<div class="attsContainer">'+
    '</div>'+
    schemaHelpEl);
    
    if (this.$parent !== undefined) {
        // add listeners for other form elements
        $('[data-mapping]', this.$parent).each($.proxy(function(index, el) {
            var formEl = $(el);
            var type = formEl.data('type');
            var mapping = formEl.data('mapping');
            // check the mapping to make sure it's an attribute
            // TODO if the data-type is hidden then the attribute should not be modifiable in this widget
            if (mapping.indexOf('custom.') === -1 &amp;&amp; mapping.indexOf('prop.') === -1) {
                var changeEl;
                if (type === 'radio') {
                    changeEl = $('input', formEl);
                } else if (type === 'textbox' || type === 'select') {
                    changeEl = formEl;
                }
                if (changeEl !== undefined) {
                    changeEl.change($.proxy(function(mapping, e) {
                        var dataObj = {};
                        dataObj[mapping] = $(e.target).val();
github GDG-Xian / crx-transit / src / js / lib / notify.js View on Github external
Notify.prototype.bind = function() {
  this.$el.hover(
    $.proxy(this.mouseover, this),
    $.proxy(this.hide, this)
  );

  var $close = this.$el.find('.transit-notify-close');
  $close.click($.proxy(this.close, this));

  // Prevent trigger transit event.
  $close.mouseup(stopPropagation);
};
github ExactTarget / fuelux / dist / datagrid.js View on Github external
return $(this).text() === pageSize.toString();
			}).attr('selected', true);
			this.options.dataOptions.pageSize = parseInt(this.$pagesize.val(), 10);
		}

		// Shim until v3 -- account for older search class:
		if (this.$searchcontrol.length &lt;= 0) {
			this.$searchcontrol = this.$element.find('.search');
		}

		this.columns = this.options.dataSource.columns();

		this.$nextpagebtn.on('click', $.proxy(this.next, this));
		this.$prevpagebtn.on('click', $.proxy(this.previous, this));
		this.$searchcontrol.on('searched cleared', $.proxy(this.searchChanged, this));
		this.$filtercontrol.on('changed', $.proxy(this.filterChanged, this));
		this.$colheader.on('click', 'th', $.proxy(this.headerClicked, this));

		if (this.$pagesize.hasClass('select')) {
			this.$pagesize.on('changed', $.proxy(this.pagesizeChanged, this));
		} else {
			this.$pagesize.on('change', $.proxy(this.pagesizeChanged, this));
		}

		this.$pageinput.on('change', $.proxy(this.pageChanged, this));

		this.renderColumns();

		if (this.options.stretchHeight) this.initStretchHeight();

		this.renderData();
	};
github ExactTarget / fuelux / vendor / fuelux-imhtheme / loader.js View on Github external
this.$element = $(element);
		this.options = $.extend({}, $.fn.wizard.defaults, options);
		this.currentStep = 1;
		this.numSteps = this.$element.find('li').length;
		this.$prevBtn = this.$element.find('button.btn-prev');
		this.$nextBtn = this.$element.find('button.btn-next');

		kids = this.$nextBtn.children().detach();
		this.nextText = $.trim(this.$nextBtn.text());
		this.$nextBtn.append(kids);

		// handle events
		this.$prevBtn.on('click', $.proxy(this.previous, this));
		this.$nextBtn.on('click', $.proxy(this.next, this));
		this.$element.on('click', 'li.complete', $.proxy(this.stepclicked, this));
	};
github ecomfe / moye / test / spec / libSpec.js View on Github external
return 'bar';
                },

                _bar: function () {
                    return this._foo();
                },

                foo: function () {
                    return this._bar();
                }
            });

            var cat = new Cat('Tom');
            expect(cat._foo).toThrow();
            expect(cat._bar).toThrow();
            expect($.proxy(cat.foo, cat)).not.toThrow();
        });
github livingdocsIO / editable.js / src / highlighting.js View on Github external
setupListeners () {
    if (this.config.checkOnFocus) {
      this.editable.on('focus', $.proxy(this, 'onFocus'))
      this.editable.on('blur', $.proxy(this, 'onBlur'))
    }
    if (this.config.checkOnChange || this.config.removeOnCorrection) {
      this.editable.on('change', $.proxy(this, 'onChange'))
    }
    if (this.config.checkOnInit) {
      this.editable.on('init', $.proxy(this, 'onInit'))
    }
  }
github roadiz / roadiz / themes / Rozier / Resources / app / widgets / LeafletGeotagField.js View on Github external
marker = this.createMarker(jsonCode, map)
                $geocodeReset.show()
            } catch (e) {
                $input.show()
                $(document.getElementById(fieldId)).hide()
                return false
            }
        } else {
            marker = this.createMarker(jsonCode, map)
        }

        marker.on('dragend', $.proxy(this.setMarkerEvent, this, marker, $input, $geocodeReset, map))
        map.on('click', $.proxy(this.setMarkerEvent, this, marker, $input, $geocodeReset, map))

        $geocodeInput.on('keypress', $.proxy(this.requestGeocode, this, marker, $input, $geocodeReset, map))
        $geocodeReset.on('click', $.proxy(this.resetMarker, this, marker, $input, $geocodeReset, map))
        window.Rozier.$window.on('resize', $.proxy(this.resetMap, this, map, marker, mapOptions))
        window.Rozier.$window.on('pageshowend', $.proxy(this.resetMap, this, map, marker, mapOptions))
        this.resetMap(map, marker, mapOptions, null)
    }
github quarterpast / Elessar / bower_components / elessar / lib / rangebar.js View on Github external
initialize: function initialize(options) {
    options = options || {};
    initialize.super$.call(this, '<div class="elessar-rangebar">');
    this.options = $.extend({}, RangeBar.defaults, options);
    this.options.min = this.options.valueParse(this.options.min);
    this.options.max = this.options.valueParse(this.options.max);
    if(this.options.barClass) this.$el.addClass(this.options.barClass);
    if(this.options.vertical) this.$el.addClass('elessar-vertical');

    this.ranges = [];
    this.on('mousemove.elessar touchmove.elessar', $.proxy(this.mousemove, this));
    this.on('mouseleave.elessar touchleave.elessar', $.proxy(this.removePhantom, this));

    if(options.values) this.setVal(options.values);

    for(var i = 0; i &lt; options.bgLabels; ++i) {
      this.addLabel(i / options.bgLabels);
    }
    var self = this;

    if(options.indicator) {
      var indicator = this.indicator = new Indicator({
        parent: this,
        vertical: this.options.vertical,
        indicatorClass: options.indicatorClass
      });
      indicator.val(this.abnormalise(options.indicator(this, indicator, function() {
        indicator.val(self.abnormalise(options.indicator(self, indicator)));</div>
github ecomfe / moye / demo / src / ui / LazyImg.js View on Github external
initialize: function (options, main) {
                options = this.setOptions(options);
                main = this.main = lib.g(options.main) || $('.' + options.main)[0];
                this.imgs = options.imgs || $('img', main).toArray();
                Lazy.add(main, $.proxy(privates.load, this), options.offset);
            }
        }).implement(lib.configurable);