Announcement

Collapse
No announcement yet.

Custom Javascript to act on generated DOM

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom Javascript to act on generated DOM

    I want to use jQuery to rewrite the href of a URL cell. I know how to write that code.
    I would like to be able to do it so that I don't have rebuild every time there is an upgrade.
    How do I include the external file? Where do I put it all?
    Can this be done?

  • #2
    It depends where you want to rewrite. If it's a field it can be easily achieved by defining a custom view in entityDefs. You just define custom view for a needed field.

    "view": "Custom:MyEntity.Fields.MyField"

    client/custom/src/views/my-entity/fields/my-field.js
    PHP Code:
    Espo.define('custom:views/my-entity/fields/my-field''views/fields/url', function (Dep) {
      
      return 
    Dep.extend({
          
    afterRender: function () {
                 
    Dep.prototype.afterRender.call(this);
                 
    // HERE WRITE YOUR LOGIC
                 
    this.$el.find('a').attr('href''your_new_url');
                
    //
         
    },
      });

    }); 
    views/fields/url is an inherited class.

    Comment

    Working...
    X