Skip to content

Commit

Permalink
wait for ACF5 to be ready
Browse files Browse the repository at this point in the history
  • Loading branch information
kraftner committed Aug 14, 2017
1 parent c765227 commit 94cddc5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions js/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ var App = function(){
App.prototype.bindListeners = function(){

if(helper.acf_version >= 5){
this.replaceVars = replaceVars.createReplaceVars(collect);
acf.add_action('change remove append sortstop', this.maybeRefresh);
acf.add_action('change remove append sortstop', replaceVars.updateReplaceVars.bind(this, collect, this.replaceVars));
var _self = this;
acf.add_action('ready', function () {
_self.replaceVars = replaceVars.createReplaceVars(collect);
acf.add_action('change remove append sortstop', _self.maybeRefresh);
acf.add_action('change remove append sortstop', replaceVars.updateReplaceVars.bind(_self, collect, _self.replaceVars));
});
}else{
var fieldSelectors = config.fieldSelectors.slice(0);

Expand Down
9 changes: 6 additions & 3 deletions js/yoast-acf-analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ var App = function(){
App.prototype.bindListeners = function(){

if(helper.acf_version >= 5){
this.replaceVars = replaceVars.createReplaceVars(collect);
acf.add_action('change remove append sortstop', this.maybeRefresh);
acf.add_action('change remove append sortstop', replaceVars.updateReplaceVars.bind(this, collect, this.replaceVars));
var _self = this;
acf.add_action('ready', function () {
_self.replaceVars = replaceVars.createReplaceVars(collect);
acf.add_action('change remove append sortstop', _self.maybeRefresh);
acf.add_action('change remove append sortstop', replaceVars.updateReplaceVars.bind(_self, collect, _self.replaceVars));
});
}else{
var fieldSelectors = config.fieldSelectors.slice(0);

Expand Down

0 comments on commit 94cddc5

Please sign in to comment.