toastrを使っておしゃれにメッセージ表示しよう!

toastrは、手軽にメッセージのトースト表示ができるjQueryプラグインです。 CSSの知識がなくても、簡単におしゃれなメッセージを作成できて便利です。 toastr及びjQueryはCybozu CDNにてサポートされているので、ご利用ください。

サンプル

計算フィールドをホバーした際に計算式を表示します。

コード

JavaScript

(function () {
  "use strict";
  kintone.events.on(["app.record.detail.show"], function (event) {
    toastr.options = { positionClass: "toast-bottom-right" };
    kintone.api("/k/v1/app/form/fields", "GET", { app: kintone.app.getId() }).then(function (response) {
        $.each(response.properties, function (fieldCode, property) {
          if (property.type !== "CALC") return;
          $(kintone.app.record.getFieldElement(fieldCode)).mouseenter(
            function () {
              toastr.info(property.expression, fieldCode);
            }
          );
        });
      });
      return event;
  });
})();