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 <parichay...@gmail.com> 
>> 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, <
>>>> parichay...@gmail.com> 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 <
>>>>>> parichay...@gmail.com> wrote:
>>>>>>
>>>>>>> Thanks Gavin. That was helpful. :)
>>>>>>>
>>>>>>> On Fri 22 May, 2020, 03:10 'Gavin Mogan' via Jenkins Developers, <
>>>>>>> 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 <
>>>>>>>> parichay...@gmail.com> 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 jenkin...@googlegroups.com.
>>>>>>>>> To view this discussion on the web visit 
>>>>>>>>> https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com
>>>>>>>>>  
>>>>>>>>> <https://groups.google.com/d/msgid/jenkinsci-dev/f24e4719-9050-4470-bbb0-f09cde79d8ad%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>>> .
>>>>>>>>>
>>>>>>>> -- 
>>>>>>>> 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 jenkin...@googlegroups.com.
>>>>>>>> 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
>>>>>>>>  
>>>>>>>> <https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuuZp%3DhZC7%3Dr%3DovyMVa72B9WqAV%2ByMbxx37kEA_uVqKZrw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>>>>> .
>>>>>>>>
>>>>>>> -- 
>>>>>>> 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 jenkin...@googlegroups.com.
>>>>>>> To view this discussion on the web visit 
>>>>>>> https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com
>>>>>>>  
>>>>>>> <https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOLKjHVGPT2uYRiHDUc2H%3DEwHxmAZtu%2BFadEdVYNKzkYA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>>>> .
>>>>>>>
>>>>>> -- 
>>>>> 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 jenkin...@googlegroups.com.
>>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/jenkinsci-dev/39bc0fbb-4657-4ef4-9625-d776a2a4d498%40googlegroups.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/jenkinsci-dev/39bc0fbb-4657-4ef4-9625-d776a2a4d498%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> -- 
>>> 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 jenkin...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/jenkinsci-dev/04e13fad-3502-4645-8d98-4b14b2b0b7fe%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/jenkinsci-dev/04e13fad-3502-4645-8d98-4b14b2b0b7fe%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
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 jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/286e1495-fc66-44a0-a751-ccbec0ead06c%40googlegroups.com.

Reply via email to