HowTo own simple textarea field with js/css assets

Hello,

i try to make a own simple (my)textarea field with no luck yet.

How does a plain textarea field without buttons should look like?

Why my JS is not running under kirby? e.g. the right click event is not catched by my JS if i run it inside kirby…hmmm.

I’ve made my desired functionality on codepen.io -> https://codepen.io/svnt/pen/EvbrdO

Any hint?

best regards,
Svnt

Have you checked out example fields of how to integrate your JS? E.g. https://github.com/jenstornell/kirby-boiler-field

1 Like

You probably need to change the data-field value. This is hardcoded and will force the panel to laod the $.fn.editor.
If you have your custom js setup something like this.

(function($) {

  $.fn.mycustomfield= function() {

    return this.each(function() {

     …

    });

  };

})(jQuery);

You would need to set the data-field attribute to mycustomfield.

class MyCustomField extends TextareaField {

  public function input() {

    $input = parent::input();
    $input->data('field', 'mycustomfield');

    return $input;

  }
  
}

Thx both of you!
With the help of @jenstornell s boiler fields it was a breeze.

Peek 2017-08-17 12-18

1 Like