Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 670f1111

Von Sven Schöling vor mehr als 11 Jahren hinzugefügt

  • ID 670f111189bc790dbcf92f35798b570da39225cd
  • Vorgänger 20576aac
  • Nachfolger 3ac83c61

PartPicker: nicht global cachen sondern mit $.data ans DOM objekt packen

Unterschiede anzeigen:

js/autocomplete_part.js
1 1
namespace('kivi', function(k){
2
  k.PartPickerCache = { }
3 2
  k.PartPicker = function($real, options) {
3
    // short circuit in case someone double inits us
4
    if ($real.data("part_picker"))
5
      return $real.data("part_picker");
6

  
4 7
    var o = $.extend({
5 8
      limit: 20,
6 9
      delay: 50,
......
151 154
    pcont.append(picker);
152 155
    picker.addClass('icon16 CRM--Schnellsuche').click(open_dialog);
153 156

  
154
    return {
157
    var pp = {
155 158
      real:           function() { return $real },
156 159
      dummy:          function() { return $dummy },
157 160
      type:           function() { return $type },
......
180 183
        });
181 184
      }
182 185
    }
186
    $real.data('part_picker', pp);
187
    return pp;
183 188
  }
184 189
});
185 190

  
186 191
$(function(){
187 192
  $('input.part_autocomplete').each(function(i,real){
188
    kivi.PartPickerCache[real.id] = new kivi.PartPicker($(real));
193
    kivi.PartPicker($(real));
189 194
  })
190 195
});
templates/webpages/part/_part_picker_result.html
26 26
[% L.paginate_controls(target='#part_picker_result', selector='#part_picker_result') %]
27 27

  
28 28
<script type='text/javascript'>
29
  var pp = kivi.PartPickerCache[$('#part_picker_real_id').val()];
30
  pp.init_results();
29
  kivi.PartPicker($('#'+$('#part_picker_real_id').val())).init_results()
31 30
</script>
templates/webpages/part/part_picker_search.html
15 15

  
16 16
<script type='text/javascript'>
17 17
  var timer;
18
  var pp = kivi.PartPickerCache['[% FORM.real_id %]'];
18
  var pp = kivi.PartPicker($('#[% FORM.real_id %]'));
19 19
  $(function(){
20 20
    $('#part_picker_filter').focus();
21 21
    pp.update_results();

Auch abrufbar als: Unified diff