Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: "Sebastien Vauban" Newsgroups: comp.lang.javascript Subject: Re: Why is .click() not effective and requires us to press on Refresh? Date: Wed, 04 Jul 2012 15:15:55 +0200 Organization: Sebastien Vauban Lines: 71 Message-ID: <80d34bbras.fsf@somewhere.org> References: <807guldukp.fsf@somewhere.org> <4ff335de$0$6179$ba4acef3@reader.news.orange.fr> <80wr2jbt4v.fsf@somewhere.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: mx04.eternal-september.org; posting-host="XagHMo1qM1HuK1lQg5GM9g"; logging-data="20648"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+1oB/D7kQSkJC7YHnPjtML" User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1 (windows-nt) X-Archive: encrypt Cancel-Lock: sha1:jN9TWe8Z0y2zEui2FtRAIHQf/GM= sha1:u1HOSWoEgajFzhTiWc/3e1RvirA= X-Url: Under construction... Xref: csiph.com comp.lang.javascript:14855 Hello, > SAM wrote: >> Le 03/07/12 12:09, Sebastien Vauban a =C3=A9crit : >>> I've made up an example of what I'm trying to achieve in >>> http://jsfiddle.net/svajquery/ttVUA/4/. >>> >>> I have "tabified" all H2, and want to click on a link in the first tab >>> ("Dashboard") and want to be redirected on the right place of the secon= d tab >>> ("Tasks"). >>> >>> While the URL is correctly displayed in the address bar of the browser = (at >>> least when testing those files in a real browser environment), the .cli= ck() is >>> not effective. >> >> the function click() can't work with a link (in "normal" JS) it was made= for >> buttons of forms (submit for instance) > > OK. Though, I'm not sure to fully understand, as it is clear that it does= work > in the following lines: > > // set the right tab as current > $('#tabs > li a[href=3D"#' + tabname + '"]').click(); > } > else { > // set the first tab as current (on page load) > $('#tabs > li a').filter(':first').click(); > >>> I must press on the Refresh button to really go where I want to. >>> >>> Do you have any explanation? I surely miss something! > > I have a gut feeling that there must be a simpler way -- however, well > beyond my JS debugging experience (simply above what I know from JS). Why= do > I think that? Because the first snippet of code (here above) works well w= ith > such links: > > - file.html sets the first tab as the current one > > - file.html#sec-2 (or file.html#tasks, if I would have given a more > significant name) sets the second tab as the current one (after an > eventual click on the browser's refresh button) > > - so does file.html#sec-2-1 (that is a link inside the second tab), with a > browser refresh > > So, such links (to individual tasks) are essentially correctly followed... > but only after a browser refresh. That's the stumbling block. > > Does this help (for helping me ;-))? > > Thank you very much in advance for your help! To ease answering on this, please find the current files used as example there: - http://www.mygooglest.com/sva/ecm-jumping-to-the-right-tab.html - http://www.mygooglest.com/sva/ecm-jumping-to-the-right-tab.js Best regards, Seb --=20 Sebastien Vauban