angular-ui / ui-tinymce

AngularUI wrapper for TinyMCE
MIT License
488 stars 371 forks source link

Bug: ng-model-options not working #252

Open shyamal890 opened 8 years ago

shyamal890 commented 8 years ago

For some reason when I utilize ng-model-options="{ updateOn: 'default blur', debounce: { 'default': 5000, 'blur': 0 } }" . Default delay of 5000 is working alright. However, onBlur doesn't trigger model update.

Example Plunker

Request: Please add version number in the tinymce.js file.

deeg commented 8 years ago

I am not sure we are set up to work with ng-model-options. I am open to supporting this if you want to put out a PR.

I will open a ticket and look into adding a version number to the tinymce.js file.

shyamal890 commented 8 years ago

@deeg I have no idea how this can be supported. however, there is something that I noticed, changes in debounce value are taken in to consideration where as blur is not.

shyamal890 commented 8 years ago

@deeg Made some changes to js file for custom debounce and blur option. Would like your take whether they are good enough as a temporary solution?

Changes: Added debouncetime and onblur to options.

//Debounce update and save action
        var debouncedUpdate = (function(debouncedUpdateDelay) {
          var debouncedUpdateTimer;
          return function(ed) {
            $timeout.cancel(debouncedUpdateTimer);
             debouncedUpdateTimer = $timeout(function() {
              return (function(ed) {
                if (ed.isDirty()) {
                  ed.save();
                  updateView(ed);
                }
              })(ed);
            }, options.debouncetime);   //CHANGED
          };
        })(400);   

ed.on('blur', function() {
              element[0].blur();
              ngModel.$setTouched();
              if (!$rootScope.$$phase) {
                scope.$digest();
              }
              if(options.onblur){
                updateView(ed);   //CHANGED
              }
            });

PLUNKER

SiriusED commented 6 years ago

Is this issue fixed or still opened?