Jump to content

Auto Focus After Ajax Refresh


Recommended Posts

Hi, I have a search DataPage and when I bulk edit my records. I want to be automatically focus on the first text box of my bulk edit window

<script type="text/javascript">
document.addEventListener('DataPageReady', function (event) {
document.getElementById("element_ID").focus();
});
</script>

I have the code above, but it is not working please help.

Link to comment
Share on other sites

Hello @Eruel,

 

I have developed a solution that does that.

 

Paste the script below in the footer of "Configure Fields for Bulk Edit Section", then update elemId to the name of your table field.

<script>

var elemId = "gist";

setTimeout(function(){
  document.querySelector(`[action*="[@cbAppKey]"] [id^=BulkEdit${elemId}]`).focus();
}, 300)

</script>

image.thumb.png.da05d9bedc0d4ee88c78c5d15aed483a.png

You might be asking why I put the code in a synchronous function setTimout. This is because there is a Caspio function that overrides the element focus after the BulkEditForm. I can't pinpoint where so I just did the setTimeout hack.

 

Hope this helps.

 

Cheers,

DN31337

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...