Issue #1780Opened February 7, 2019by AkibDeraiya1230 reactions

How to change extra dropdown for link change trait

Question

Hello @artf , I want to give one more functionality to user like user can change any link with default links drop down.

screenshot 5

In above image i want to add one more dropdown for the default links.

If user will select the links from the drop-down then also need to change href of selected link and on other hand if user will type link into href input text-box(marked in above image) then also need to change the href of selected links.

How can i do this things can you please help me?

Answers (3)

AkibDeraiya123February 11, 20190 reactions

Hello @artf If i only want to do in change trait for href(<a ) tag then how can i change that? I tried like,

    var dType = domComps.getType('default');
    var dModel = dType.model;
    var dView = dType.view;

    domComps.addType('a', {
      model: dModel.extend({
        defaults: Object.assign({}, dModel.prototype.defaults, {
          traits: [
            // strings are automatically converted to text types
            {
              type: 'select',
              label: 'Href',
              name: 'href',
              options: [
                {value: 'index.html', name: 'Home'},
                {value: 'index2.html', name: 'Home2'},
                {value: 'index3.html', name: 'Home3'},
                {value: 'index4.html', name: 'Home4'},
              ]
            }
          ],
        }),
      }, {
        isComponent: function(el) {
          if(el.tagName == 'a'){
            return {type: 'a'};
          }
        },
      }),

      view: dView,
    });```

But this is something like not works. Can you please help me at where i am doing wrong?
AkibDeraiya123February 12, 20190 reactions

And one more question, how can i check the selected DOM element's type? I guess it will use isComponent function. But i don't know how to use it and where?

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.