On Tue, Nov 8, 2016 at 4:38 PM, D R <rir....@gmail.com> wrote:

> Hi,
>
> Nobody here who can help me fix the Javascript Extension?
>
> Regards,
> Dennis
>
>
> 2016-11-04 14:18 GMT+01:00 D R <rir....@gmail.com>:
>
> > Hi community,
> >
> > I'm having a hard time getting a Javascript Extension for an
> > AppWithinMinutes livetable to work.
> >
> > I have several livetable "enhancements" in it like changing background
> > color per field value which work properly.
> >
> > As a reference I've used the example:
> > http://snippets.xwiki.org/xwiki/bin/view/Extension/
> Background+color+for+a+
> > livetable
> >
> > Now I want to change the display of the value of a specific column, for
> > example to display an image or a button next to the value. This works
> only
> > for the last column in the livetable. All other rows look strange.
> >
> > Example:
> >
> > The simplified code:
> > ```
>


> > document.observe("xwiki:livetable:newrow", function(ev){
> >   $$('.sTxtUser').each(function(element){
>

Debug your code and you'll see that:

* the xwiki:livetable:newrow event is fired for each row in the live table
* $$('.sTxtUser') selects all the existing cells

So whenever a row is displayed you process not only that row but also the
existing rows that have been displayed before..


> >     var content = element.innerText;
> >     if(content === undefined){
> >       content = element.textContent;
> >     }
> >     element.replace('<td class="sTxtUser link typetext"
> > data-title="Username">"' + content + '"</td>')
> >   });
> > });
> >
> > ```
> >
> > I have 3 documents for the application with the following values for
> field
> > sTxtUser :
> > testuser1
> > test12345
> > anotheruser1
> >
> > Using the above extension renders the livetable cells like this:
> > """anotheruser1"""
> > ""test12345""
> > "testuser1"
> >
> > If I change the sort order:
> > """testuser1"""
> > ""test12345""
> > "anotheruser1"
> >
> > So only the last row shows the desired output.
> >
> > What am I doing wrong?
> >
> > Regards,
> > Dennis
> >
> _______________________________________________
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
>
_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to