<a href="blah.html" id="foo">Link</a>

    $('foo').observe('click',function(event) {
        if(my_qualifier!=true) {
Event.stop(event);
}
});

nice and simple


Alex Mcauley
http://www.thevacancymarket.com
----- Original Message ----- 
From: "david" <david.brill...@gmail.com>
To: "Prototype & script.aculo.us" <prototype-scriptaculous@googlegroups.com>
Sent: Tuesday, September 15, 2009 7:22 AM
Subject: [Proto-Scripty] Re: Coding disabled on a link



Hi Arnaud,
a finger mistakle on the previous answer, sorry.

If you want to disable a link depending on some condition, there is
some soution based on event:
- set the onclick attribute of the link point to a js function that
return false when you don't want the link to be clickabke
- with prototype, observe the click event, and if your condition show
that button is disabled, just set the event.preventDefualt property to
true, so the link is like it is not active.

There is just one thing that you should take care is to modify CSS
property for the "a" element, so that when it's disable, you could
change some property.

Is that the meaning of your question?

--
david

On 14 sep, 17:52, "Arnaud F." <arnaud.fe...@gmail.com> wrote:
> Hello,
>
> i need to disable a link in some case.
>
> What I do actually is something like this :
>
> <html>
> <head>
> <script src="javascript/prototype.js" type="text/javascript"></
> script>
> </head>
> <body>
> <script type="text/javascript">
> var a_create = new Element('a', {
> id : 'btn_create',
> href : 'javascript:linkOnClick();',
> innerText : '[ Create ]'});
>
> var l_create = new Element('label',{id:'btn_create',
> innerText:'[ Create ]'});
>
> function linkOnClick() {
> $('btn_create').replace(l_create);
> alert("disabled");
> }
>
> function activateLink() {
> $('btn_create').replace(a_create);
> alert("activate");
> }
> </script>
>
> <label id="btn_create">[ Create ]</label>
> <input type="button" onclick="javascript:activateLink();"
> value="Activate link" />
> </body>
> </html>
>
> It works fine but, It's possible to do much easier ? If not, how can I
> override only the link tag whitout modifying other Elements?
>
> Thanks !



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to