4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

kintoneの画像スライドショーからクリックでレコードを開く

Last updated at Posted at 2018-03-04

どういうこと?

こういうことです。

demo.gif

kintoneのデフォルトの機能では、添付ファイルのサムネイルをスライドショーで表示できますが、その写真をクリックしても該当のレコードを開いてくれません。
そこでJavaScriptでカスタマイズすることにしました。

コード

(function(){
    document.body.addEventListener('DOMNodeInserted', function(event){
        if(event.target.className == 'slideshow-cybozu'){
            var slideshow = event.target;
            slideshow.addEventListener('DOMNodeInserted', function(event){
                if(event.target.tagName == 'IMG'){
                    var img = event.target;
                    if(img.parentElement.className.includes('slide-image-cybozu')){
                        img.style.cursor = 'pointer';
                        img.onclick = function(){
                            var params = new URLSearchParams(img.src);
                            var rec_id = params.get('record');
                            open(`/k/${kintone.app.getId()}/show#record=${rec_id}`);
                        }
                    }
                }
            });
        }
    })
})();

インストール方法

kintoneのヘルプを参照して下さい。

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?