Unique IDs for Repeatable Content

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

Unique IDs for Repeatable Content

domi@fortysix.ch
can anyone point me to a successfully usage example of unique id generation by
following the pattern described at https://wiki.jenkins-ci.org/display/JENKINS/Unique+IDs+for+Repeatable+Content ?

Domi

Reply | Threaded
Open this post in threaded view
|

Re: Unique IDs for Repeatable Content

Alan Harder-2
See the big red box at the top of that wiki page :-)


On 04/22/11 08:33, Domi wrote:
> can anyone point me to a successfully usage example of unique id generation by
> following the pattern described at https://wiki.jenkins-ci.org/display/JENKINS/Unique+IDs+for+Repeatable+Content ?
>
> Domi
>
Reply | Threaded
Open this post in threaded view
|

Re: Unique IDs for Repeatable Content

domi@fortysix.ch
I did, but in the text below there it states:
...Starting in Hudson 1.350 you can generate unique ids...
so this must be wrong then... sorry, but I think I just don't get it



On 22.04.2011, at 18:59, Alan Harder wrote:

> See the big red box at the top of that wiki page :-)
>
>
> On 04/22/11 08:33, Domi wrote:
>> can anyone point me to a successfully usage example of unique id generation by
>> following the pattern described at https://wiki.jenkins-ci.org/display/JENKINS/Unique+IDs+for+Repeatable+Content ?
>>
>> Domi
>>

Reply | Threaded
Open this post in threaded view
|

Re: Unique IDs for Repeatable Content

Alan Harder-2
The red box at the top supersedes the greyed out box below it.. I crossed
out the "in Hudson 1.350" part now.


On 4/23/11 2:56 AM, Domi wrote:

> I did, but in the text below there it states:
> ...Starting in Hudson 1.350 you can generate unique ids...
> so this must be wrong then... sorry, but I think I just don't get it
>
>
>
> On 22.04.2011, at 18:59, Alan Harder wrote:
>
>> See the big red box at the top of that wiki page :-)
>>
>>
>> On 04/22/11 08:33, Domi wrote:
>>> can anyone point me to a successfully usage example of unique id generation by
>>> following the pattern described at https://wiki.jenkins-ci.org/display/JENKINS/Unique+IDs+for+Repeatable+Content ?
>>>
>>> Domi
>>>
Reply | Threaded
Open this post in threaded view
|

Re: Unique IDs for Repeatable Content

domi@fortysix.ch
So I guess I should tell you that:  "yes the scheme described in the grey box would help me" :)
I really wonder if I'm the only one (or first) who needs to address an element in a repeatable block with JavaScript...
regards Domi


On 23.04.2011, at 17:31, Alan Harder wrote:

> The red box at the top supersedes the greyed out box below it.. I crossed out the "in Hudson 1.350" part now.
>
>
> On 4/23/11 2:56 AM, Domi wrote:
>> I did, but in the text below there it states:
>> ...Starting in Hudson 1.350 you can generate unique ids...
>> so this must be wrong then... sorry, but I think I just don't get it
>>
>>
>>
>> On 22.04.2011, at 18:59, Alan Harder wrote:
>>
>>> See the big red box at the top of that wiki page :-)
>>>
>>>
>>> On 04/22/11 08:33, Domi wrote:
>>>> can anyone point me to a successfully usage example of unique id generation by
>>>> following the pattern described at https://wiki.jenkins-ci.org/display/JENKINS/Unique+IDs+for+Repeatable+Content ?
>>>>
>>>> Domi
>>>>

Reply | Threaded
Open this post in threaded view
|

Re: Unique IDs for Repeatable Content

Alan Harder-2
You should first see if your need for ids can be refactored such that you
can just use classes (as I was able to do with the original reason I wrote
that code/wiki page).  Also for <label> there is <label
class="attach-previous">.


On 4/23/11 9:08 AM, Domi wrote:

> So I guess I should tell you that:  "yes the scheme described in the grey box would help me" :)
> I really wonder if I'm the only one (or first) who needs to address an element in a repeatable block with JavaScript...
> regards Domi
>
>
> On 23.04.2011, at 17:31, Alan Harder wrote:
>
>> The red box at the top supersedes the greyed out box below it.. I crossed out the "in Hudson 1.350" part now.
>>
>>
>> On 4/23/11 2:56 AM, Domi wrote:
>>> I did, but in the text below there it states:
>>> ...Starting in Hudson 1.350 you can generate unique ids...
>>> so this must be wrong then... sorry, but I think I just don't get it
>>>
>>>
>>>
>>> On 22.04.2011, at 18:59, Alan Harder wrote:
>>>
>>>> See the big red box at the top of that wiki page :-)
>>>>
>>>>
>>>> On 04/22/11 08:33, Domi wrote:
>>>>> can anyone point me to a successfully usage example of unique id generation by
>>>>> following the pattern described at https://wiki.jenkins-ci.org/display/JENKINS/Unique+IDs+for+Repeatable+Content ?
>>>>>
>>>>> Domi
>>>>>
Reply | Threaded
Open this post in threaded view
|

Re: Unique IDs for Repeatable Content

domi@fortysix.ch
OK, 
is there a way to find out whether my element (<textarea>) is within a repeated chunck?
The problem is that for each repeatable a hidden copy is available on the page and for this one my javascript gets executed too.
I tried 'isInsideRemovable(e)' but that does not work either. So I created:
function isInsideRepeatedChunk(e) {
    return Element.ancestors(e).find(function(f){return f.hasClassName("repeated-chunk");});
}
...but no luck

On 24.04.2011, at 17:15, Alan Harder wrote:

You should first see if your need for ids can be refactored such that you can just use classes (as I was able to do with the original reason I wrote that code/wiki page).  Also for <label> there is <label class="attach-previous">.


On 4/23/11 9:08 AM, Domi wrote:
So I guess I should tell you that:  "yes the scheme described in the grey box would help me" :)
I really wonder if I'm the only one (or first) who needs to address an element in a repeatable block with JavaScript...
regards Domi


On 23.04.2011, at 17:31, Alan Harder wrote:

The red box at the top supersedes the greyed out box below it.. I crossed out the "in Hudson 1.350" part now.


On 4/23/11 2:56 AM, Domi wrote:
I did, but in the text below there it states:
...Starting in Hudson 1.350 you can generate unique ids...
so this must be wrong then... sorry, but I think I just don't get it



On 22.04.2011, at 18:59, Alan Harder wrote:

See the big red box at the top of that wiki page :-)


On 04/22/11 08:33, Domi wrote:
can anyone point me to a successfully usage example of unique id generation by
following the pattern described at https://wiki.jenkins-ci.org/display/JENKINS/Unique+IDs+for+Repeatable+Content ?

Domi


Reply | Threaded
Open this post in threaded view
|

Re: Unique IDs for Repeatable Content

Alan Harder-2
Where are you putting this javascript, and what is it for?
If it is something to be done when a new instance of a repeated chunk is added/initialized, you can use a Behavior.register call to register a handler for a new class type..



On 04/25/11 01:10, Domi wrote:
OK, 
is there a way to find out whether my element (<textarea>) is within a repeated chunck?
The problem is that for each repeatable a hidden copy is available on the page and for this one my javascript gets executed too.
I tried 'isInsideRemovable(e)' but that does not work either. So I created:
function isInsideRepeatedChunk(e) {
    return Element.ancestors(e).find(function(f){return f.hasClassName("repeated-chunk");});
}
...but no luck

On 24.04.2011, at 17:15, Alan Harder wrote:

You should first see if your need for ids can be refactored such that you can just use classes (as I was able to do with the original reason I wrote that code/wiki page).  Also for <label> there is <label class="attach-previous">.


On 4/23/11 9:08 AM, Domi wrote:
So I guess I should tell you that:  "yes the scheme described in the grey box would help me" :)
I really wonder if I'm the only one (or first) who needs to address an element in a repeatable block with JavaScript...
regards Domi


On 23.04.2011, at 17:31, Alan Harder wrote:

The red box at the top supersedes the greyed out box below it.. I crossed out the "in Hudson 1.350" part now.


On 4/23/11 2:56 AM, Domi wrote:
I did, but in the text below there it states:
...Starting in Hudson 1.350 you can generate unique ids...
so this must be wrong then... sorry, but I think I just don't get it



On 22.04.2011, at 18:59, Alan Harder wrote:

See the big red box at the top of that wiki page :-)


On 04/22/11 08:33, Domi wrote:
can anyone point me to a successfully usage example of unique id generation by
following the pattern described at https://wiki.jenkins-ci.org/display/JENKINS/Unique+IDs+for+Repeatable+Content ?

Domi


Reply | Threaded
Open this post in threaded view
|

Re: Unique IDs for Repeatable Content

domi@fortysix.ch
The javascript is to add a dynamic code parser to a repeatable textarea (containing a groovy script) the parser will then highlight the groovy syntax:  http://codemirror.net/manual.html 

      var editor = CodeMirror.fromTextArea(document.getElementById("gscript"), {
        lineNumbers: true,
        matchBrackets: true,
        mode: "text/x-groovy"
      });

I'm already using the same library from within scriptler-plugin and the groovy-portbuild-plugin - all working fine...
But now I'm trying to do the same for the groovy-plugin which I currently still fail... :(
I did already try 'Behavior.register' too:
config.jelly:
<textarea class="groovyscript" name="groovy.command" style="width:100%; height:20em">
  <j:out value="${instance.scriptSource.command}" />
</textarea>
<script>
var myRules = {
    "TEXTAREA.groovyscript" : function(e) {
        var editor = CodeMirror.fromTextArea( e , {
        lineNumbers: true,
        matchBrackets: true,
        mode: "text/x-groovy"
    });
    }
    }
};
Behaviour.register(myRules);
</script>

But this still ends in to many editors registered.
thanks for your help

On 25.04.2011, at 17:52, Alan Harder wrote:

Where are you putting this javascript, and what is it for?
If it is something to be done when a new instance of a repeated chunk is added/initialized, you can use a Behavior.register call to register a handler for a new class type..



On 04/25/11 01:10, Domi wrote:
OK, 
is there a way to find out whether my element (<textarea>) is within a repeated chunck?
The problem is that for each repeatable a hidden copy is available on the page and for this one my javascript gets executed too.
I tried 'isInsideRemovable(e)' but that does not work either. So I created:
function isInsideRepeatedChunk(e) {
    return Element.ancestors(e).find(function(f){return f.hasClassName("repeated-chunk");});
}
...but no luck

On 24.04.2011, at 17:15, Alan Harder wrote:

You should first see if your need for ids can be refactored such that you can just use classes (as I was able to do with the original reason I wrote that code/wiki page).  Also for <label> there is <label class="attach-previous">.


On 4/23/11 9:08 AM, Domi wrote:
So I guess I should tell you that:  "yes the scheme described in the grey box would help me" :)
I really wonder if I'm the only one (or first) who needs to address an element in a repeatable block with JavaScript...
regards Domi


On 23.04.2011, at 17:31, Alan Harder wrote:

The red box at the top supersedes the greyed out box below it.. I crossed out the "in Hudson 1.350" part now.


On 4/23/11 2:56 AM, Domi wrote:
I did, but in the text below there it states:
...Starting in Hudson 1.350 you can generate unique ids...
so this must be wrong then... sorry, but I think I just don't get it



On 22.04.2011, at 18:59, Alan Harder wrote:

See the big red box at the top of that wiki page :-)


On 04/22/11 08:33, Domi wrote:
can anyone point me to a successfully usage example of unique id generation by
following the pattern described at https://wiki.jenkins-ci.org/display/JENKINS/Unique+IDs+for+Repeatable+Content ?

Domi



Reply | Threaded
Open this post in threaded view
|

Re: Unique IDs for Repeatable Content

Alan Harder-2
ya, that looks pretty good.. I'd think it would work if that <script> was outside the repeatable.. not sure how to get it there.  Maybe the first thing to try is wrapping that <script> block in <st:once>.. not sure if that'll work, but worth a try.


On 4/25/11 11:45 AM, Domi wrote:
The javascript is to add a dynamic code parser to a repeatable textarea (containing a groovy script) the parser will then highlight the groovy syntax:  http://codemirror.net/manual.html 

      var editor = CodeMirror.fromTextArea(document.getElementById("gscript"), {
        lineNumbers: true,
        matchBrackets: true,
        mode: "text/x-groovy"
      });

I'm already using the same library from within scriptler-plugin and the groovy-portbuild-plugin - all working fine...
But now I'm trying to do the same for the groovy-plugin which I currently still fail... :(
I did already try 'Behavior.register' too:
config.jelly:
<textarea class="groovyscript" name="groovy.command" style="width:100%; height:20em">
  <j:out value="${instance.scriptSource.command}" />
</textarea>
<script>
var myRules = {
    "TEXTAREA.groovyscript" : function(e) {
        var editor = CodeMirror.fromTextArea( e , {
        lineNumbers: true,
        matchBrackets: true,
        mode: "text/x-groovy"
    });
    }
    }
};
Behaviour.register(myRules);
</script>

But this still ends in to many editors registered.
thanks for your help

On 25.04.2011, at 17:52, Alan Harder wrote:

Where are you putting this javascript, and what is it for?
If it is something to be done when a new instance of a repeated chunk is added/initialized, you can use a Behavior.register call to register a handler for a new class type..



On 04/25/11 01:10, Domi wrote:
OK, 
is there a way to find out whether my element (<textarea>) is within a repeated chunck?
The problem is that for each repeatable a hidden copy is available on the page and for this one my javascript gets executed too.
I tried 'isInsideRemovable(e)' but that does not work either. So I created:
function isInsideRepeatedChunk(e) {
    return Element.ancestors(e).find(function(f){return f.hasClassName("repeated-chunk");});
}
...but no luck

On 24.04.2011, at 17:15, Alan Harder wrote:

You should first see if your need for ids can be refactored such that you can just use classes (as I was able to do with the original reason I wrote that code/wiki page).  Also for <label> there is <label class="attach-previous">.


On 4/23/11 9:08 AM, Domi wrote:
So I guess I should tell you that:  "yes the scheme described in the grey box would help me" :)
I really wonder if I'm the only one (or first) who needs to address an element in a repeatable block with JavaScript...
regards Domi


On 23.04.2011, at 17:31, Alan Harder wrote:

The red box at the top supersedes the greyed out box below it.. I crossed out the "in Hudson 1.350" part now.


On 4/23/11 2:56 AM, Domi wrote:
I did, but in the text below there it states:
...Starting in Hudson 1.350 you can generate unique ids...
so this must be wrong then... sorry, but I think I just don't get it



On 22.04.2011, at 18:59, Alan Harder wrote:

See the big red box at the top of that wiki page :-)


On 04/22/11 08:33, Domi wrote:
can anyone point me to a successfully usage example of unique id generation by
following the pattern described at https://wiki.jenkins-ci.org/display/JENKINS/Unique+IDs+for+Repeatable+Content ?

Domi



Reply | Threaded
Open this post in threaded view
|

Re: Unique IDs for Repeatable Content

domi@fortysix.ch
Alan,
you are my personal hero! the <st:once> tag solved 70% of all the problems!
Now I can digg into it to see why I'm not able to store the content of the textareas anymore...
It seems that because of the missing ID the codemirror library is not able to make the association between the original field and the new enhanced (by the codeparser). I'll probably have to check this with the guys from codemirror - guess IDs would solve many issues here :)
thanks Alan!


On 26.04.2011, at 16:40, Alan Harder wrote:

ya, that looks pretty good.. I'd think it would work if that <script> was outside the repeatable.. not sure how to get it there.  Maybe the first thing to try is wrapping that <script> block in <st:once>.. not sure if that'll work, but worth a try.


On 4/25/11 11:45 AM, Domi wrote:
The javascript is to add a dynamic code parser to a repeatable textarea (containing a groovy script) the parser will then highlight the groovy syntax:  http://codemirror.net/manual.html 

      var editor = CodeMirror.fromTextArea(document.getElementById("gscript"), {
        lineNumbers: true,
        matchBrackets: true,
        mode: "text/x-groovy"
      });

I'm already using the same library from within scriptler-plugin and the groovy-portbuild-plugin - all working fine...
But now I'm trying to do the same for the groovy-plugin which I currently still fail... :(
I did already try 'Behavior.register' too:
config.jelly:
<textarea class="groovyscript" name="groovy.command" style="width:100%; height:20em">
  <j:out value="${instance.scriptSource.command}" />
</textarea>
<script>
var myRules = {
    "TEXTAREA.groovyscript" : function(e) {
        var editor = CodeMirror.fromTextArea( e , {
        lineNumbers: true,
        matchBrackets: true,
        mode: "text/x-groovy"
    });
    }
    }
};
Behaviour.register(myRules);
</script>

But this still ends in to many editors registered.
thanks for your help

On 25.04.2011, at 17:52, Alan Harder wrote:

Where are you putting this javascript, and what is it for?
If it is something to be done when a new instance of a repeated chunk is added/initialized, you can use a Behavior.register call to register a handler for a new class type..



On 04/25/11 01:10, Domi wrote:
OK, 
is there a way to find out whether my element (<textarea>) is within a repeated chunck?
The problem is that for each repeatable a hidden copy is available on the page and for this one my javascript gets executed too.
I tried 'isInsideRemovable(e)' but that does not work either. So I created:
function isInsideRepeatedChunk(e) {
    return Element.ancestors(e).find(function(f){return f.hasClassName("repeated-chunk");});
}
...but no luck

On 24.04.2011, at 17:15, Alan Harder wrote:

You should first see if your need for ids can be refactored such that you can just use classes (as I was able to do with the original reason I wrote that code/wiki page).  Also for <label> there is <label class="attach-previous">.


On 4/23/11 9:08 AM, Domi wrote:
So I guess I should tell you that:  "yes the scheme described in the grey box would help me" :)
I really wonder if I'm the only one (or first) who needs to address an element in a repeatable block with JavaScript...
regards Domi


On 23.04.2011, at 17:31, Alan Harder wrote:

The red box at the top supersedes the greyed out box below it.. I crossed out the "in Hudson 1.350" part now.


On 4/23/11 2:56 AM, Domi wrote:
I did, but in the text below there it states:
...Starting in Hudson 1.350 you can generate unique ids...
so this must be wrong then... sorry, but I think I just don't get it



On 22.04.2011, at 18:59, Alan Harder wrote:

See the big red box at the top of that wiki page :-)


On 04/22/11 08:33, Domi wrote:
can anyone point me to a successfully usage example of unique id generation by
following the pattern described at https://wiki.jenkins-ci.org/display/JENKINS/Unique+IDs+for+Repeatable+Content ?

Domi