Hi all,
I want to attach a jQuery script to an anchor element while keeping the regular anchor appearance (i mean that web browsers render it like any other anchor, being focusable), and to be triggered under the same conditions a callback would (clicked / pressing a key while having focus). I can attach the script by sending html anchor onClick: aScript; onKeyDown:aScript but then the printed anchor looks on the web browser like regular text and don't get foucs. Best, Laura _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Laura,
the appearance of an anchor is not dependent on whether it has event handlers attached to it. So I guess there is more to it thant just onClick and onKeyDown. The best thing to find out what's foing on is to look at the anchor in your web browser's dev tools and see what styles are in place for your anchor. This sure helps you find the reason for the change in its rendering. Joachim Am 18.02.15 um 04:58 schrieb Laura Risani:
-- ----------------------------------------------------------------------- Objektfabrik Joachim Tuchel [hidden email] Fliederweg 1 http://www.objektfabrik.de D-71640 Ludwigsburg http://joachimtuchel.wordpress.com Telefon: +49 7141 56 10 86 0 Fax: +49 7141 56 10 86 1 _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by laura
Hi Laura,
You need to include an href attribute with the anchor. Seaside puts one when you add a callback and if you do not need that (like in your example), you can set the href yourself using the #url: message. We typically set the href to ‘javascript:{}’ html anchor url:’javascript:{}’; onClick: aScript; onKeyDown:aScript Also see this discussion: http://stackoverflow.com/questions/10510191/valid-to-use-a-anchor-tag-without-href-attribute/10510353#10510353 cheers, Johan
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Wow, so I learned something again ;-)
Am 18.02.15 um 09:33 schrieb Johan Brichau: Hi Laura, -- ----------------------------------------------------------------------- Objektfabrik Joachim Tuchel [hidden email] Fliederweg 1 http://www.objektfabrik.de D-71640 Ludwigsburg http://joachimtuchel.wordpress.com Telefon: +49 7141 56 10 86 0 Fax: +49 7141 56 10 86 1 _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
[hidden email] wrote:
> Wow, so I learned something again ;-) > > Am 18.02.15 um 09:33 schrieb Johan Brichau: >> Hi Laura, >> >> You need to include an href attribute with the anchor. >> Seaside puts one when you add a callback and if you do not need that >> (like in your example), you can set the href yourself using the #url: >> message. >> >> We typically set the href to ‘javascript:{}’ >> >> html anchor url:’javascript:{}’; onClick: aScript; onKeyDown:aScript >> >> Also see this discussion: >> http://stackoverflow.com/questions/10510191/valid-to-use-a-anchor-tag-without-href-attribute/10510353#10510353 >> >> cheers, >> Johan >> >>> On 18 Feb 2015, at 04:58, Laura Risani <[hidden email] >>> <mailto:[hidden email]>> wrote: >>> >>> Hi all, >>> >>> I want to attach a jQuery script to an anchor element while keeping >>> the regular anchor appearance (i mean that web browsers render it >>> like any other anchor, being focusable), and to be triggered under >>> the same conditions a callback would (clicked / pressing a key while >>> having focus). >>> >>> I can attach the script by sending >>> html anchor onClick: aScript; onKeyDown:aScript >>> but then the printed anchor looks on the web browser like regular >>> text and don't get foucs. >>> >>> Best, >>> Laura >>> _______________________________________________ >>> seaside mailing list >>> [hidden email] >>> <mailto:[hidden email]> >>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside >> >> >> >> _______________________________________________ >> seaside mailing list >> [hidden email] >> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > > given to the anchor, so either set a href as being suggested to, or set a callback. _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by jtuchel
Thank you Joachim and Johan for your answers. I had tried adding "callback:[]" but that renders the whole page again. Very interesting the discussion on SO about the semantic and functional nature of the anchor tag. On Wed, Feb 18, 2015 at 6:13 AM, [hidden email] <[hidden email]> wrote:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Laura,
> I had tried adding "callback:[]" but that renders the whole page again. That’s to be expected. I just wanted to make clear that if you do not add a callback, you need to set a url (href attribute) yourself or the browser will not show it as a (clickable) link. Johan_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Seems that same anchor-like rendering by web browsers can be achieved with url:'#' (instead of url:’javascript:{}’ ). On Wed, Feb 18, 2015 at 4:17 PM, Johan Brichau <[hidden email]> wrote: Laura, _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Laura,
That will make your page scroll to the top. Not always desirable… Johan
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Hi Johan. I thought for a moment it would do something else... I'll stick then with url:’javascript:{}’ Best, Laura On Mon, Mar 2, 2015 at 4:43 PM, Johan Brichau <[hidden email]> wrote:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
I'm facing a problem with this code that we mentioned html anchor url:’javascript:{}’; onClick: aScript; onKeyDown:aScript the problem is that when pressing enter key (while the anchor has focus) triggers onKeyDown: (and variants) twice, while pressing any other key just does it (as desired) once. Is there a way to override this undesired behavior of enter key? On Mon, Mar 2, 2015 at 6:13 PM, Laura Risani <[hidden email]> wrote:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Seems that pressing keys space/enter also triggers onClick: . I changed the code to button bePush onClick:aScript and so onClick: is triggered just once whether for click/any keypress. Best, Laura On Mon, Mar 2, 2015 at 8:37 PM, Laura Risani <[hidden email]> wrote:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
I'm not sure but you might could have also just used a 'return false;' at the end of your script to shut off the default behavior.
|
Didn't now you can shut down default behavior, interesting. On Wed, Mar 4, 2015 at 6:54 PM, Paul DeBruicker <[hidden email]> wrote: I'm not sure but you might could have also just used a 'return false;' at the _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Mind that that prevents default browser behavior.
You can prevent a link from getting keyboard focus by setting a negative tabIndex property: https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex The result is that it will never be able to respond to an enter using it’s click handler. cheers Johan
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |