[Question] How to add value to a field dynamically in the UI?

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

[Question] How to add value to a field dynamically in the UI?

Parichay Barpanda
Hi,

I want to set value of a Describable field using an UI button. There is a text box Token and there is a button Generate, if Generate Button is clicked then Token text box should be filled with a desired value. 

Thanks and Regards,
Parichay

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Question] How to add value to a field dynamically in the UI?

Gavin Mogan
document.getElementById("buttonid").addEventListener(function(e) {
       document.getElementById("idname").value = "foo";
});

On Thu, May 21, 2020 at 2:27 PM Parichay Barpanda <[hidden email]> wrote:
Hi,

I want to set value of a Describable field using an UI button. There is a text box Token and there is a button Generate, if Generate Button is clicked then Token text box should be filled with a desired value. 

Thanks and Regards,
Parichay

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Question] How to add value to a field dynamically in the UI?

Parichay Barpanda
Thanks Gavin. That was helpful. :)

On Fri 22 May, 2020, 03:10 'Gavin Mogan' via Jenkins Developers, <[hidden email]> wrote:
document.getElementById("buttonid").addEventListener(function(e) {
       document.getElementById("idname").value = "foo";
});

On Thu, May 21, 2020 at 2:27 PM Parichay Barpanda <[hidden email]> wrote:
Hi,

I want to set value of a Describable field using an UI button. There is a text box Token and there is a button Generate, if Generate Button is clicked then Token text box should be filled with a desired value. 

Thanks and Regards,
Parichay

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Question] How to add value to a field dynamically in the UI?

Gavin Mogan
Sorry, I got distracted when i hit enter.
you want a click event for the button

document.getElementById("buttonid").addEventListener('click', function(e) {
       document.getElementById("idname").value = "foo";
});



On Thu, May 21, 2020 at 3:11 PM Parichay Barpanda <[hidden email]> wrote:
Thanks Gavin. That was helpful. :)

On Fri 22 May, 2020, 03:10 'Gavin Mogan' via Jenkins Developers, <[hidden email]> wrote:
document.getElementById("buttonid").addEventListener(function(e) {
       document.getElementById("idname").value = "foo";
});

On Thu, May 21, 2020 at 2:27 PM Parichay Barpanda <[hidden email]> wrote:
Hi,

I want to set value of a Describable field using an UI button. There is a text box Token and there is a button Generate, if Generate Button is clicked then Token text box should be filled with a desired value. 

Thanks and Regards,
Parichay

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuvEvqtwtSrYOHbNo7aaZ1S6dO_cofdbknKpbsFDjnTc8w%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Question] How to add value to a field dynamically in the UI?

Parichay Barpanda
Np. 

I am trying to create a button element:

f.entry() {
    raw("""
        <button class="gen-secret">
            Generate Secret Token
        </button>
    """)
}

then the listener:

raw("""
    <script>
        document.getElementByClassName("gen-secret").addEventListener('click', function(e) {
            e.preventDefault();
            document.getElementByClassName("secret-text").value = token;
        });
    </script>
""")


So when I click on the button it takes me to home page. How can I prevent this behaviour?

On Friday, May 22, 2020 at 3:51:45 AM UTC+5:30, Gavin Mogan wrote:
Sorry, I got distracted when i hit enter.
you want a click event for the button

document.getElementById("buttonid").addEventListener('click', function(e) {
       document.getElementById("idname").value = "foo";
});



On Thu, May 21, 2020 at 3:11 PM Parichay Barpanda <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="5lhhHvnFAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">parichay...@...> wrote:
Thanks Gavin. That was helpful. :)

On Fri 22 May, 2020, 03:10 'Gavin Mogan' via Jenkins Developers, <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="5lhhHvnFAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkin...@googlegroups.com> wrote:
document.getElementById("buttonid").addEventListener(function(e) {
       document.getElementById("idname").value = "foo";
});

On Thu, May 21, 2020 at 2:27 PM Parichay Barpanda <<a href="javascript:" rel="nofollow" target="_blank" gdf-obfuscated-mailto="5lhhHvnFAgAJ" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">parichay...@...> wrote:
Hi,

I want to set value of a Describable field using an UI button. There is a text box Token and there is a button Generate, if Generate Button is clicked then Token text box should be filled with a desired value. 

Thanks and Regards,
Parichay

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" rel="nofollow" target="_blank" gdf-obfuscated-mailto="5lhhHvnFAgAJ" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkin...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" rel="nofollow" target="_blank" gdf-obfuscated-mailto="5lhhHvnFAgAJ" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkin...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="5lhhHvnFAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkin...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/39bc0fbb-4657-4ef4-9625-d776a2a4d498%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Question] How to add value to a field dynamically in the UI?

Gavin Mogan
Get element by class name returns an array. It should have spit out an error in your browser console.

Id = one
Class = sharable = many

I'm guessing the button is inside a form or something? A button by itself won't do any page navigation, and it should need to be a submit button to submit a form, but maybe by default if there's only a single button browser treats it as a submit.

I would say if you fix your errors, then it shouldn't redirect with prevent default


On Thu., May 21, 2020, 3:37 p.m. Parichay Barpanda, <[hidden email]> wrote:
Np. 

I am trying to create a button element:

f.entry() {
    raw("""
        <button class="gen-secret">
            Generate Secret Token
        </button>
    """)
}

then the listener:

raw("""
    <script>
        document.getElementByClassName("gen-secret").addEventListener('click', function(e) {
            e.preventDefault();
            document.getElementByClassName("secret-text").value = token;
        });
    </script>
""")


So when I click on the button it takes me to home page. How can I prevent this behaviour?

On Friday, May 22, 2020 at 3:51:45 AM UTC+5:30, Gavin Mogan wrote:
Sorry, I got distracted when i hit enter.
you want a click event for the button

document.getElementById("buttonid").addEventListener('click', function(e) {
       document.getElementById("idname").value = "foo";
});



On Thu, May 21, 2020 at 3:11 PM Parichay Barpanda <[hidden email]> wrote:
Thanks Gavin. That was helpful. :)

On Fri 22 May, 2020, 03:10 'Gavin Mogan' via Jenkins Developers, <[hidden email]> wrote:
document.getElementById("buttonid").addEventListener(function(e) {
       document.getElementById("idname").value = "foo";
});

On Thu, May 21, 2020 at 2:27 PM Parichay Barpanda <[hidden email]> wrote:
Hi,

I want to set value of a Describable field using an UI button. There is a text box Token and there is a button Generate, if Generate Button is clicked then Token text box should be filled with a desired value. 

Thanks and Regards,
Parichay

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/39bc0fbb-4657-4ef4-9625-d776a2a4d498%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DusBX%2BTGNQWgLAjes84RauwAHc_8-Sz7hFoKjrEmS5RtEQ%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Question] How to add value to a field dynamically in the UI?

Parichay Barpanda
Yes having adding an Id to the element instead of class solves the problem. But this config is inside a repeatableHeteroProperty which means there could be multiple buttons with the same ids which will change multiple fields so it is an issue. Can I some way get the index of individual properties?

On Friday, May 22, 2020 at 4:17:04 AM UTC+5:30, Gavin Mogan wrote:
Get element by class name returns an array. It should have spit out an error in your browser console.

Id = one
Class = sharable = many

I'm guessing the button is inside a form or something? A button by itself won't do any page navigation, and it should need to be a submit button to submit a form, but maybe by default if there's only a single button browser treats it as a submit.

I would say if you fix your errors, then it shouldn't redirect with prevent default


On Thu., May 21, 2020, 3:37 p.m. Parichay Barpanda, <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="HmNKxlrHAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">parichay...@...> wrote:
Np. 

I am trying to create a button element:

f.entry() {
    raw("""
        <button class="gen-secret">
            Generate Secret Token
        </button>
    """)
}

then the listener:

raw("""
    <script>
        document.getElementByClassName("gen-secret").addEventListener('click', function(e) {
            e.preventDefault();
            document.getElementByClassName("secret-text").value = token;
        });
    </script>
""")


So when I click on the button it takes me to home page. How can I prevent this behaviour?

On Friday, May 22, 2020 at 3:51:45 AM UTC+5:30, Gavin Mogan wrote:
Sorry, I got distracted when i hit enter.
you want a click event for the button

document.getElementById("buttonid").addEventListener('click', function(e) {
       document.getElementById("idname").value = "foo";
});



On Thu, May 21, 2020 at 3:11 PM Parichay Barpanda <[hidden email]> wrote:
Thanks Gavin. That was helpful. :)

On Fri 22 May, 2020, 03:10 'Gavin Mogan' via Jenkins Developers, <[hidden email]> wrote:
document.getElementById("buttonid").addEventListener(function(e) {
       document.getElementById("idname").value = "foo";
});

On Thu, May 21, 2020 at 2:27 PM Parichay Barpanda <[hidden email]> wrote:
Hi,

I want to set value of a Describable field using an UI button. There is a text box Token and there is a button Generate, if Generate Button is clicked then Token text box should be filled with a desired value. 

Thanks and Regards,
Parichay

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" rel="nofollow" target="_blank" gdf-obfuscated-mailto="HmNKxlrHAgAJ" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkin...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/39bc0fbb-4657-4ef4-9625-d776a2a4d498%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/39bc0fbb-4657-4ef4-9625-d776a2a4d498%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/39bc0fbb-4657-4ef4-9625-d776a2a4d498%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/39bc0fbb-4657-4ef4-9625-d776a2a4d498%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/04e13fad-3502-4645-8d98-4b14b2b0b7fe%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Question] How to add value to a field dynamically in the UI?

Gavin Mogan
So it looks like forEach doesn't work in ie11 - https://caniuse.com/#feat=mdn-api_nodelist_foreach, so you'll have to use a normal loop, something like

var buttons = document.getElementByClassName("gen-secret")
for (var i = 0; i < buttons.length; i++) {
   buttons[i].addEventListener('click', function(e) {
            e.preventDefault();
            document.getElementByClassName("secret-text").value = token;
        });
}

On Thu, May 21, 2020 at 3:54 PM Parichay Barpanda <[hidden email]> wrote:
Yes having adding an Id to the element instead of class solves the problem. But this config is inside a repeatableHeteroProperty which means there could be multiple buttons with the same ids which will change multiple fields so it is an issue. Can I some way get the index of individual properties?

On Friday, May 22, 2020 at 4:17:04 AM UTC+5:30, Gavin Mogan wrote:
Get element by class name returns an array. It should have spit out an error in your browser console.

Id = one
Class = sharable = many

I'm guessing the button is inside a form or something? A button by itself won't do any page navigation, and it should need to be a submit button to submit a form, but maybe by default if there's only a single button browser treats it as a submit.

I would say if you fix your errors, then it shouldn't redirect with prevent default


On Thu., May 21, 2020, 3:37 p.m. Parichay Barpanda, <[hidden email]> wrote:
Np. 

I am trying to create a button element:

f.entry() {
    raw("""
        <button class="gen-secret">
            Generate Secret Token
        </button>
    """)
}

then the listener:

raw("""
    <script>
        document.getElementByClassName("gen-secret").addEventListener('click', function(e) {
            e.preventDefault();
            document.getElementByClassName("secret-text").value = token;
        });
    </script>
""")


So when I click on the button it takes me to home page. How can I prevent this behaviour?

On Friday, May 22, 2020 at 3:51:45 AM UTC+5:30, Gavin Mogan wrote:
Sorry, I got distracted when i hit enter.
you want a click event for the button

document.getElementById("buttonid").addEventListener('click', function(e) {
       document.getElementById("idname").value = "foo";
});



On Thu, May 21, 2020 at 3:11 PM Parichay Barpanda <[hidden email]> wrote:
Thanks Gavin. That was helpful. :)

On Fri 22 May, 2020, 03:10 'Gavin Mogan' via Jenkins Developers, <[hidden email]> wrote:
document.getElementById("buttonid").addEventListener(function(e) {
       document.getElementById("idname").value = "foo";
});

On Thu, May 21, 2020 at 2:27 PM Parichay Barpanda <[hidden email]> wrote:
Hi,

I want to set value of a Describable field using an UI button. There is a text box Token and there is a button Generate, if Generate Button is clicked then Token text box should be filled with a desired value. 

Thanks and Regards,
Parichay

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/39bc0fbb-4657-4ef4-9625-d776a2a4d498%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/04e13fad-3502-4645-8d98-4b14b2b0b7fe%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DusUWdnXZDc8WzbXAbrKeFTS1TawhJdj5WcwRQqpH89C7w%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Question] How to add value to a field dynamically in the UI?

Parichay Barpanda
I am kinda confused bcz this doesn't solve my problem. If I click on a button then the secret-text of that particular property should change but if all buttons have same listener then all secret-text fields will change. I want some ability to set different id to buttons in different properties(read: array inside repeatableHeteroProperty).

On Friday, May 22, 2020 at 4:29:43 AM UTC+5:30, Gavin Mogan wrote:
So it looks like forEach doesn't work in ie11 - <a href="https://caniuse.com/#feat=mdn-api_nodelist_foreach" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fcaniuse.com%2F%23feat%3Dmdn-api_nodelist_foreach\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEZ54Nl_BOQJRPlvHP1v5rkb-_Llg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fcaniuse.com%2F%23feat%3Dmdn-api_nodelist_foreach\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEZ54Nl_BOQJRPlvHP1v5rkb-_Llg&#39;;return true;">https://caniuse.com/#feat=mdn-api_nodelist_foreach, so you'll have to use a normal loop, something like

var buttons = document.getElementByClassName("gen-secret")
for (var i = 0; i < buttons.length; i++) {
   buttons[i].addEventListener('click', function(e) {
            e.preventDefault();
            document.getElementByClassName("secret-text").value = token;
        });
}

On Thu, May 21, 2020 at 3:54 PM Parichay Barpanda <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="SF14ZgvIAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">parichay...@...> wrote:
Yes having adding an Id to the element instead of class solves the problem. But this config is inside a repeatableHeteroProperty which means there could be multiple buttons with the same ids which will change multiple fields so it is an issue. Can I some way get the index of individual properties?

On Friday, May 22, 2020 at 4:17:04 AM UTC+5:30, Gavin Mogan wrote:
Get element by class name returns an array. It should have spit out an error in your browser console.

Id = one
Class = sharable = many

I'm guessing the button is inside a form or something? A button by itself won't do any page navigation, and it should need to be a submit button to submit a form, but maybe by default if there's only a single button browser treats it as a submit.

I would say if you fix your errors, then it shouldn't redirect with prevent default


On Thu., May 21, 2020, 3:37 p.m. Parichay Barpanda, <[hidden email]> wrote:
Np. 

I am trying to create a button element:

f.entry() {
    raw("""
        <button class="gen-secret">
            Generate Secret Token
        </button>
    """)
}

then the listener:

raw("""
    <script>
        document.getElementByClassName("gen-secret").addEventListener('click', function(e) {
            e.preventDefault();
            document.getElementByClassName("secret-text").value = token;
        });
    </script>
""")


So when I click on the button it takes me to home page. How can I prevent this behaviour?

On Friday, May 22, 2020 at 3:51:45 AM UTC+5:30, Gavin Mogan wrote:
Sorry, I got distracted when i hit enter.
you want a click event for the button

document.getElementById("buttonid").addEventListener('click', function(e) {
       document.getElementById("idname").value = "foo";
});



On Thu, May 21, 2020 at 3:11 PM Parichay Barpanda <[hidden email]> wrote:
Thanks Gavin. That was helpful. :)

On Fri 22 May, 2020, 03:10 'Gavin Mogan' via Jenkins Developers, <[hidden email]> wrote:
document.getElementById("buttonid").addEventListener(function(e) {
       document.getElementById("idname").value = "foo";
});

On Thu, May 21, 2020 at 2:27 PM Parichay Barpanda <[hidden email]> wrote:
Hi,

I want to set value of a Describable field using an UI button. There is a text box Token and there is a button Generate, if Generate Button is clicked then Token text box should be filled with a desired value. 

Thanks and Regards,
Parichay

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/39bc0fbb-4657-4ef4-9625-d776a2a4d498%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/39bc0fbb-4657-4ef4-9625-d776a2a4d498%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/39bc0fbb-4657-4ef4-9625-d776a2a4d498%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/39bc0fbb-4657-4ef4-9625-d776a2a4d498%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="SF14ZgvIAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkin...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/04e13fad-3502-4645-8d98-4b14b2b0b7fe%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/04e13fad-3502-4645-8d98-4b14b2b0b7fe%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/04e13fad-3502-4645-8d98-4b14b2b0b7fe%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/04e13fad-3502-4645-8d98-4b14b2b0b7fe%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/a87febe9-ecc5-473c-bd0b-09a683f5ce02%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Question] How to add value to a field dynamically in the UI?

Parichay Barpanda
I made a hacky solution for this by padding a random 4 digit number to secret-textbox and gen-button with RandomStringUtils.randomNumeric(4). The possibility of conflicts is less as number of properties added is usually 1-2 (max 5). What do you think?

On Friday, May 22, 2020 at 4:36:36 AM UTC+5:30, Parichay Barpanda wrote:
I am kinda confused bcz this doesn't solve my problem. If I click on a button then the secret-text of that particular property should change but if all buttons have same listener then all secret-text fields will change. I want some ability to set different id to buttons in different properties(read: array inside repeatableHeteroProperty).

On Friday, May 22, 2020 at 4:29:43 AM UTC+5:30, Gavin Mogan wrote:
So it looks like forEach doesn't work in ie11 - <a href="https://caniuse.com/#feat=mdn-api_nodelist_foreach" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fcaniuse.com%2F%23feat%3Dmdn-api_nodelist_foreach\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEZ54Nl_BOQJRPlvHP1v5rkb-_Llg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fcaniuse.com%2F%23feat%3Dmdn-api_nodelist_foreach\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEZ54Nl_BOQJRPlvHP1v5rkb-_Llg&#39;;return true;">https://caniuse.com/#feat=mdn-api_nodelist_foreach, so you'll have to use a normal loop, something like

var buttons = document.getElementByClassName("gen-secret")
for (var i = 0; i < buttons.length; i++) {
   buttons[i].addEventListener('click', function(e) {
            e.preventDefault();
            document.getElementByClassName("secret-text").value = token;
        });
}

On Thu, May 21, 2020 at 3:54 PM Parichay Barpanda <[hidden email]> wrote:
Yes having adding an Id to the element instead of class solves the problem. But this config is inside a repeatableHeteroProperty which means there could be multiple buttons with the same ids which will change multiple fields so it is an issue. Can I some way get the index of individual properties?

On Friday, May 22, 2020 at 4:17:04 AM UTC+5:30, Gavin Mogan wrote:
Get element by class name returns an array. It should have spit out an error in your browser console.

Id = one
Class = sharable = many

I'm guessing the button is inside a form or something? A button by itself won't do any page navigation, and it should need to be a submit button to submit a form, but maybe by default if there's only a single button browser treats it as a submit.

I would say if you fix your errors, then it shouldn't redirect with prevent default


On Thu., May 21, 2020, 3:37 p.m. Parichay Barpanda, <[hidden email]> wrote:
Np. 

I am trying to create a button element:

f.entry() {
    raw("""
        <button class="gen-secret">
            Generate Secret Token
        </button>
    """)
}

then the listener:

raw("""
    <script>
        document.getElementByClassName("gen-secret").addEventListener('click', function(e) {
            e.preventDefault();
            document.getElementByClassName("secret-text").value = token;
        });
    </script>
""")


So when I click on the button it takes me to home page. How can I prevent this behaviour?

On Friday, May 22, 2020 at 3:51:45 AM UTC+5:30, Gavin Mogan wrote:
Sorry, I got distracted when i hit enter.
you want a click event for the button

document.getElementById("buttonid").addEventListener('click', function(e) {
       document.getElementById("idname").value = "foo";
});



On Thu, May 21, 2020 at 3:11 PM Parichay Barpanda <[hidden email]> wrote:
Thanks Gavin. That was helpful. :)

On Fri 22 May, 2020, 03:10 'Gavin Mogan' via Jenkins Developers, <[hidden email]> wrote:
document.getElementById("buttonid").addEventListener(function(e) {
       document.getElementById("idname").value = "foo";
});

On Thu, May 21, 2020 at 2:27 PM Parichay Barpanda <[hidden email]> wrote:
Hi,

I want to set value of a Describable field using an UI button. There is a text box Token and there is a button Generate, if Generate Button is clicked then Token text box should be filled with a desired value. 

Thanks and Regards,
Parichay

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/39bc0fbb-4657-4ef4-9625-d776a2a4d498%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/39bc0fbb-4657-4ef4-9625-d776a2a4d498%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/39bc0fbb-4657-4ef4-9625-d776a2a4d498%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/39bc0fbb-4657-4ef4-9625-d776a2a4d498%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/04e13fad-3502-4645-8d98-4b14b2b0b7fe%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/04e13fad-3502-4645-8d98-4b14b2b0b7fe%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/04e13fad-3502-4645-8d98-4b14b2b0b7fe%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/04e13fad-3502-4645-8d98-4b14b2b0b7fe%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/286e1495-fc66-44a0-a751-ccbec0ead06c%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Question] How to add value to a field dynamically in the UI?

Gavin Mogan
Thats probably fine

you can also use like element.parentNode and classlist (https://stackoverflow.com/questions/31608928/event-target-classlist-doesnt-have-indexof-method) to find the right node, but depending on your dom structure your way is probably easier)

buttons[i].addEventListener('click', function(e) {
            e.preventDefault();
var container = e.target;
while ( container.parentNode &&  container.parentNode.classList.indexOf('repeatable-property');
container =  container .parentNode;
}
           container getElementByClassName("secret-text")[0].value = token;
        });

On Thu, May 21, 2020 at 4:27 PM Parichay Barpanda <[hidden email]> wrote:
I made a hacky solution for this by padding a random 4 digit number to secret-textbox and gen-button with RandomStringUtils.randomNumeric(4). The possibility of conflicts is less as number of properties added is usually 1-2 (max 5). What do you think?

On Friday, May 22, 2020 at 4:36:36 AM UTC+5:30, Parichay Barpanda wrote:
I am kinda confused bcz this doesn't solve my problem. If I click on a button then the secret-text of that particular property should change but if all buttons have same listener then all secret-text fields will change. I want some ability to set different id to buttons in different properties(read: array inside repeatableHeteroProperty).

On Friday, May 22, 2020 at 4:29:43 AM UTC+5:30, Gavin Mogan wrote:
So it looks like forEach doesn't work in ie11 - https://caniuse.com/#feat=mdn-api_nodelist_foreach, so you'll have to use a normal loop, something like

var buttons = document.getElementByClassName("gen-secret")
for (var i = 0; i < buttons.length; i++) {
   buttons[i].addEventListener('click', function(e) {
            e.preventDefault();
            document.getElementByClassName("secret-text").value = token;
        });
}

On Thu, May 21, 2020 at 3:54 PM Parichay Barpanda <[hidden email]> wrote:
Yes having adding an Id to the element instead of class solves the problem. But this config is inside a repeatableHeteroProperty which means there could be multiple buttons with the same ids which will change multiple fields so it is an issue. Can I some way get the index of individual properties?

On Friday, May 22, 2020 at 4:17:04 AM UTC+5:30, Gavin Mogan wrote:
Get element by class name returns an array. It should have spit out an error in your browser console.

Id = one
Class = sharable = many

I'm guessing the button is inside a form or something? A button by itself won't do any page navigation, and it should need to be a submit button to submit a form, but maybe by default if there's only a single button browser treats it as a submit.

I would say if you fix your errors, then it shouldn't redirect with prevent default


On Thu., May 21, 2020, 3:37 p.m. Parichay Barpanda, <[hidden email]> wrote:
Np. 

I am trying to create a button element:

f.entry() {
    raw("""
        <button class="gen-secret">
            Generate Secret Token
        </button>
    """)
}

then the listener:

raw("""
    <script>
        document.getElementByClassName("gen-secret").addEventListener('click', function(e) {
            e.preventDefault();
            document.getElementByClassName("secret-text").value = token;
        });
    </script>
""")


So when I click on the button it takes me to home page. How can I prevent this behaviour?

On Friday, May 22, 2020 at 3:51:45 AM UTC+5:30, Gavin Mogan wrote:
Sorry, I got distracted when i hit enter.
you want a click event for the button

document.getElementById("buttonid").addEventListener('click', function(e) {
       document.getElementById("idname").value = "foo";
});



On Thu, May 21, 2020 at 3:11 PM Parichay Barpanda <[hidden email]> wrote:
Thanks Gavin. That was helpful. :)

On Fri 22 May, 2020, 03:10 'Gavin Mogan' via Jenkins Developers, <[hidden email]> wrote:
document.getElementById("buttonid").addEventListener(function(e) {
       document.getElementById("idname").value = "foo";
});

On Thu, May 21, 2020 at 2:27 PM Parichay Barpanda <[hidden email]> wrote:
Hi,

I want to set value of a Describable field using an UI button. There is a text box Token and there is a button Generate, if Generate Button is clicked then Token text box should be filled with a desired value. 

Thanks and Regards,
Parichay

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/39bc0fbb-4657-4ef4-9625-d776a2a4d498%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/04e13fad-3502-4645-8d98-4b14b2b0b7fe%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/286e1495-fc66-44a0-a751-ccbec0ead06c%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_Duv%2Bh%3DNeM2F1dKJsKGU64XZk4esF5Hrq8X6ZAHCMd3dsNQ%40mail.gmail.com.