easyautocomplete - Opening links in new tab

130 Views Asked by At

I am using the links template and would like to open the links in a new tab (target=_blank). Is there an easy way to do this?

template: {
                type: "links",
                fields: {
                    link: "url"
                }
            }, ...
1

There are 1 best solutions below

0
Aref On

Ended up modifying the source template.js and `if(template.type === "links") {

            if (typeof _fields.link === "string") {
                buildMethod = function(elementValue, element) {
                    return "<a href='" + element[_fields.link] + "' >" + elementValue + "</a>";
                };                  
            } else if (typeof _fields.link === "function") {
                buildMethod = function(elementValue, element) {
                    return "<a href='" + _fields.link(element) + "' >" + elementValue + "</a>";
                };
            }

            return buildMethod;
        }`

and added target='_blank' (crude but works for this purpose). Wish CSS was able to address target behavior sort of how it does for hover.