How to disable link?

Pretty much the title.


squiffy.ui.output.on('click', function() {
disableLink("#theIdOfYourLink");
});
would be one way to do it. You might have to remove the "#" and just write "theIdOfYourLink" instead, haven't tried. Usually Squiffy handles link disabling, so you wouldn't need to do this.

Please note that Squiffy DOES NOT properly disable the link, it just changes the colour of the link and sets its tabindex to "-1", which means it's focusable by script but not by the user's keyboard. For better handling of this you'd have to additionally call
$("#theIdOfYourLink").prop("disabled", "disabled");


Below is a copy of response to an issue in GitHub about disabling links as a future feature of native squiffy.

Instead of disabling the links it replaces the link with plain text. It's a nasty hack but it works to a degree without the the need to get into JavaScript so the standard editor will handle it.

It might prompt a better idea for what you are trying to do?


Imperfect and partial workaround until @deactivate is implemented.
Just in case it is useful for someone wanting to do something like this.

Viewing bbb will deactivate ccc link.
Viewing ccc will deactivate bbb link.

[aaa], {label:bc=[bbb], [ccc]}, [ddd]

[aaa]:
aaa example text

[bbb]:
@replace bc=bbb, ccc
bbb example text

[ccc]:
@replace bc=bbb, ccc
ccc example text

[ddd]:
ddd example text

Of course, JFox and I are like nemesises - we always have different ways to do it.

A simple way to disable a link might be this - I've used this a lot of time in games.

[[set variables]]:

    //this represents the game going in. disableFlg will disable the link.
    //use "@set not disableFlg" to allow it to work.

@set disableFlg

[[links]]

[[links]]:

Try to chose the option...

{if disableFlg:Option}
{else:[[Option]](picked)}

[[picked]]:

Yes, you picked me.

Nice. I like it!


This topic is now closed. Topics are closed after 180 days of inactivity.

Support

Forums