Issue #821Opened January 30, 2018by Deepak8130 reactions

How to set the href attribute

Question

Hi @artf,

Please let us know how we can set the href attribute of anchor inside div when element is dragged i.e

<div class="social_icons rrssb-buttons c3250"> <a href="https://www.facebook.com/sharer/sharer.php?u=http://starteo.softobiz.com" class="popup rrssb-facebook" id="ibvm"><i aria-hidden="true" class="facebookSocial fa fa-facebook"> </i></a> <a href="https://twitter.com/intent/tweet?text=https://rrssb.netlify.com/" class="popup rrssb-twitter" id="iuhg"><i aria-hidden="true" class="fa fa-twitter" id="iayz"> </i></a> <a href="mailto:?Subject=your%20subject" class="rrssb-email" id="i6ji"><i aria-hidden="true" class="fa fa-envelope" id="icv33"> </i></a> <a href="http://www.linkedin.com/shareArticle?mini=true&url=http://rrssb.ml&title=Ridiculously%20Responsive%20Social%20Sharing%20Buttons&summary=Responsive%20social%20icons%20by%20KNI%20Labs" class="popup rrssb-linkedin" id="ii5ni"><i aria-hidden="true" class="fa fa-linkedin" id="i0ukq"> </i></a> </div>

I want to update href of first anchor tag without using editor.getHTML() but using below code it add href on div i.e

model.set('attributes', {'href': 'https://www.facebook.com/sharer/sharer.php?u='});

I am using latest library.

Answers (3)

JulyanoFJanuary 30, 20180 reactions

@Deepak813 I guess that it isn't in model, it should be something like: editor.getSelected().set('href', 'https://www.facebook.com/sharer/sharer.php?u=') You don't need to access model

Deepak813January 30, 20180 reactions

Hi @JulyanoF,

Thanks for the message,

I have used this code when element is dragged but display following error:

Uncaught TypeError: Cannot read property 'set' of null.

As i want to update the href of anchor tag inside the div when element is dragged.

JulyanoFJanuary 30, 20180 reactions

@Deepak813 Oh, you want to change anchor when is draggin/dropping?

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.