Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Howto place cursor after Add -> Page directly in Title-Field? (jQuery? AJS?)

Sven
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 18, 2011

Hello,

so often the users forget to fill in the Title of a page. It would be of great help, if after Add -> Page, the cursor would be placed in the title field and not in the WYSIWG-content-field (new editor).

I've been trying some "jQuery magic", but it's not working.

What's wrong?

I tried:

<script>
jQuery(document).ready(function() {
    // on add -> page, set focus on title, not on content
    jQuery("#content-title").focus();

    jQuery("#input:text:visible:first").focus(); 
});
</script>

Thanks for any suggestion,

Sven

7 answers

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 21, 2011

try http://stackoverflow.com/questions/290254/how-to-order-events-bound-with-jquery or http://stackoverflow.com/questions/827107/jquery-mulitple-click-handlers-how-to-ensure-order-of-firing. You might be better off just making a source hack though. Also yeah, the iframe may change things, not sure...

0 votes
Sven
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 21, 2011

/EDIT

AJS.toInit() changed nothing ;-(

/EDIT

Ah yes... 4.x changed the whole editor thing. So this is the reason ;-)

Thanks for your suggestions, I'll try this... I've seen that the "new" editor sits in an iframe, does this change something? Maybe?

If you have suggestions (links to useful information) about how to make a handler fire at last, don't hesitate...

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 19, 2011

Ah yes, sounds like another dom ready handler is also setting focus. BTW I tried it on an older version, 3.4.9, maybe it's changed. You could try AJS.toInit(..) instead of AJS.$(). It's also possible with some javascript to make your handler fire last, but it's a bit of a pain...

0 votes
Sven
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 19, 2011

/EDIT

I've tested in Chrome and yes, there cursor "hops" for a millisecond to the title field (it clears the text "Please enter title") and then jumps back into the main edit field...

???

Looks like there is another mechanism which is stronger to bring the cursor back in the main edit field ;-/

/EDIT

yeah, I've inserted it into "Custom HTML - before end of head" - maybe that's too early? The new editor is in an iframe (but not the title), perhaps this is the reason?

Could you try to insert it there and tell me if it still works for you?

Thanks anyway!

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 18, 2011

I just pasted it into the Chrome console... press f12. Or same in firefox with firebug...

0 votes
Sven
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 18, 2011

Thanks for trying!

Hmm. How I can do a console.log from javascript? Where did you put the code exactly?

(in the meanwhile I've a lot of jQuery-Hacks, maybe another "hack" is disabling this ;-)

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 18, 2011

Worked for me (tm). Is the JS definitely running? Try an alert or console.log statement,

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events