【问题标题】:Script to change name stops after Dynamic selection动态选择后更改名称的脚本停止
【发布时间】:2015-04-09 06:25:42
【问题描述】:

到目前为止,我需要更改 Adob​​e Business Catalyst 中无法访问的模块中的文本,但是一旦屏幕上的选项更新,脚本就不会再次运行。如何让它自动刷新/运行?

    $(document).ready(function(){
$.fn.replaceText = function( search, replace, text_only ) {
  return this.each(function(){
    var node = this.firstChild,
      val,
      new_val,
      remove = [];
    if ( node ) {
      do {
        if ( node.nodeType === 3 ) {
          val = node.nodeValue;
          new_val = val.replace( search, replace );
          if ( new_val !== val ) {
            if ( !text_only && /</.test( new_val ) ) {
              $(node).before( new_val );
              remove.push( node );
            } else {
              node.nodeValue = new_val;
            }
          }
        }
      } while ( node = node.nextSibling );
    }
    remove.length && $(remove).remove();
  });
};
$("#shippingStateSpan").replaceText( "Destination State", "Do you have a VAT number?" );
});

任何帮助将不胜感激。谢谢

【问题讨论】:

    标签: java rename business-catalyst


    【解决方案1】:

    我猜当页面上选择的选项发生更改时,文本会被替换。试试这个:

    $(document).ready(function() {
    $.fn.replaceText = function(search, replace, text_only) {
        return this.each(function() {
            var node = this.firstChild,
                val,
                new_val,
                remove = [];
            if (node) {
                do {
                    if (node.nodeType === 3) {
                        val = node.nodeValue;
                        new_val = val.replace(search, replace);
                        if (new_val !== val) {
                            if (!text_only && /</.test(new_val)) {
                                $(node).before(new_val);
                                remove.push(node);
                            } else {
                                node.nodeValue = new_val;
                            }
                        }
                    }
                } while (node = node.nextSibling);
            }
            remove.length && $(remove).remove();
        });
    };
    var refreshIds = setInterval('$("#shippingStateSpan").replaceText( "Destination State", "Do you have a VAT number?" )', 300);
    });
    

    【讨论】:

    • 必须将其更改为目的地状态而不是运输选项,但它现在可以工作了!感谢您的帮助!
    • 抱歉 - 忘了我已经更改了一些项目,以便在给你解决方案之前进行自我测试,我会更新以匹配你的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-24
    • 2016-10-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多