Hi,
Try this:
$fileList.each('tr', function()) {
var $tr = $(this);
var fileid = $tr.attr('data-id');
var owner = $tr.attr('data-share-owner');
var path = $tr.attr('data-path') || fileList.getCurrentDirectory();
var fileName = $tr.attr('data-name');
// ...
})
If you only want the rows that have "data-share-owner" set, change the
selector to:
$fileList.each('tr[data-share-owner]', function()) {
Try and avoid using innerHTML / outerHTML as it is inefficient,
especially when there is a long list of items.
Cheers,
Vincent
On 06/18/2014 12:53 PM, Hoffmann, Patrick wrote:
> Hello Vincent,
>
> I just need to access data-share-owner and data-id. I saw that it's in the
> <tr>, but I'd like to use the context variable.
>
> $('#content').delegate('#fileList', 'fileActionsReady',function(ev){
>
> var $fileList = ev.fileList.$fileList;
>
>
> $fileList.find('tr').each(function(fileid,$file){
> //Some filtering to get
> data-share-owner and data-id with $file.outerHTML
> });
> });
>
> No possibility to grab the attributes easier?....
> Path is no problem... My script is handling it already (oc_path
> $('#dir').val() +'/'+filename;). I could use your way, sure that is not the
> problem.
>
> Cheers
>
> Patrick
>
> Von: [email protected] [mailto:[email protected]] Im
> Auftrag von Vincent Petry
> Gesendet: Mittwoch, 18. Juni 2014 12:40
> An: List for Developers of ownCloud
> Betreff: Re: [owncloud-devel] WG: OC7a JS context object
>
> Hi Patrick,
>
> The reason for the delegate is because you need to know in which list the
> event was fired.
> If you don't use it it means you need to call ".on('fileActionsReady')" on
> every list explicitly, but you cannot know how many lists exist and some of
> them are not created until you navigate there.
>
> One issue you will meet is that you need the full file path, not only the
> path.
> I suggest to change the inner most function to:
>
> var fileList = ev.fileList;
> var $fileList = fileList.$fileList;
>
> $fileList.each('tr', function() {
> var $tr = $(this);
> var fileName = $tr.attr('data-name');
> var path = $tr.attr('data-path') || fileList.getCurrentDirectory();
> getState(path + '/' + fileName, "true");
> });
>
> Reading "nametext" might be slow. As you can see the "data-name" and
> "data-path" contain the information you need. Note that in "All files" the
> "data-path" is not defined, so we default to the current directory of the
> list.
>
> Hope this helps.
>
> Cheers,
>
> Vincent
> On 06/18/2014 11:55 AM, Hoffmann, Patrick wrote:
>
>
>
> Gesch?ftsf?hrer: Werner Magin, Winfried Schmuck | HRB 2704 Bad Kreuznach |
> Gesellschafter: Fritz Bittmann Holding GmbH | USt-ID: DE 811 202 181
>
>
> BITO-Lagertechnik
> Bittmann GmbH
> Obertor 29
> D-55590 Meisenheim Telefon:
> Telefax:
> E-Mail:
> Internet: +49 (0) 6753 122 0
> +49 (0) 6753 122 399
> [email protected]
> www.bito.de
>
>
>
> Dieses E-Mail ist nur f?r den Empf?nger bestimmt, an den es gerichtet ist und
> kann vertrauliches bzw. unter das Berufsgeheimnis fallendes Material
> enthalten. Jegliche darin enthaltene Ansicht oder Meinungs?u?erung ist die
> des Autors und stellt nicht notwendigerweise die Ansicht oder Meinung von
> BITO-Lagertechnik Bittmann GmbH dar.
> Sind Sie nicht der Empf?nger und haben diese E-Mail irrt?mlich erhalten, sind
> jegliche Verwendung, Ver?ffentlichung, Weiterleitung, Abschrift oder
> jeglicher Druck dieser E-Mail strengstens untersagt.
> Jede ausgehende E-Mail wird von uns mit h?chster Sorgfalt auf Viren gepr?ft.
> Jedoch ?bernehmen weder BITO-Lagertechnik Bittmann GmbH noch der Absender
> (Patrick Hoffmann) die Haftung f?r Viren; es obliegt Ihrer Verantwortung, die
> E-Mail und deren Anh?nge auf Viren zu pr?fen.
>
> This email is exclusively meant for the addressee and may contain
> confidential information or information which can be classified as
> professional secret. Any view or opinion stated in this email is that of the
> author and does not necessarily represent the view or the opinion of
> BITO-Lagertechnik Bittmann GmbH. If you are not the addressee and if this
> email has been transmitted to you by mistake, you may not make use of,
> publish, transmit, reproduce or print the information contained therein for
> whatever purpose. We take every reasonable care to check all out-bound emails
> for viruses. However, neither BITO-Lagertechnik Bittmann GmbH nor the sender
> (Patrick Hoffmann) can be held liable for the occurrence of viruses and any
> consequential damages. It is therefore the addressee's sole responsibility to
> check incoming emails and attachments for viruses.
>
> Anh?nge - :
> Versand am 18.06.2014 12:53 von Patrick Hoffmann
>
>
>
>
> Hello Vincent,
>
>
>
> you sample code was useful.
>
> I could shorten my auto update. I have now
>
>
>
> $('#content').delegate('#fileList', 'fileActionsReady',function(ev){
>
>
>
> var $fileList = ev.fileList.$fileList;
>
>
>
> $fileList.find('tr td.filename a.name
> span.nametext').each(function(fileid,file){
>
>
> getState(file.innerText,"true");
>
> });
>
> });
>
>
>
> But I still need a good way to access the
> context.$file.attr('data-share-owner') in a for each style.
>
> I don't see the advantage of using delegate. I'd like to modify the function
> getState(filename,safemode) to
>
> getState(filename,owner,safemode)
>
>
>
> Cheers
>
>
>
> Patrick
>
>
>
> Von: [email protected]<mailto:[email protected]>
> [mailto:[email protected]] Im Auftrag von Vincent Petry
>
> Gesendet: Dienstag, 17. Juni 2014 16:08
>
> An: List for Developers of ownCloud
>
> Betreff: Re: [owncloud-devel] WG: OC7a JS context object
>
>
>
> Hi Patrick,
>
>
>
> You need to use a delegate to catch that file list event higher in the DOM.
>
> There is an example in apps/files_sharing/js/share.js line 74:
>
>
>
> $('#content').delegate('#fileList',
> 'fileActionsReady',function(ev){
>
> var fileList = ev.fileList;
>
>
>
> then from here you could add:
>
>
>
> var $fileList = fileList.$fileList;
>
> $fileList.find('tr td.filename a.name span.nametext')
>
> // etc ...
>
>
>
> The delegate construct and the current event system isn't that intuitive.
>
> I will add it to the dev docs as well when I get to it.
>
>
>
> Cheers,
>
>
>
> Vincent
>
>
>
>
>
>
>
>
>
> Gesch?ftsf?hrer: Werner Magin, Winfried Schmuck | HRB 2704 Bad Kreuznach |
> Gesellschafter: Fritz Bittmann Holding GmbH | USt-ID: DE 811 202 181
>
>
>
>
>
> BITO-Lagertechnik
>
> Bittmann GmbH
>
> Obertor 29
>
> D-55590 Meisenheim Telefon:
>
> Telefax:
>
> E-Mail:
>
> Internet: +49 (0) 6753 122 0
>
> +49 (0) 6753 122 399
>
> [email protected]<mailto:[email protected]>
>
> www.bito.de<http://www.bito.de>
>
>
>
>
>
>
>
> Dieses E-Mail ist nur f?r den Empf?nger bestimmt, an den es gerichtet ist und
> kann vertrauliches bzw. unter das Berufsgeheimnis fallendes Material
> enthalten. Jegliche darin enthaltene Ansicht oder Meinungs?u?erung ist die
> des Autors und stellt nicht notwendigerweise die Ansicht oder Meinung von
> BITO-Lagertechnik Bittmann GmbH dar.
>
> Sind Sie nicht der Empf?nger und haben diese E-Mail irrt?mlich erhalten, sind
> jegliche Verwendung, Ver?ffentlichung, Weiterleitung, Abschrift oder
> jeglicher Druck dieser E-Mail strengstens untersagt.
>
> Jede ausgehende E-Mail wird von uns mit h?chster Sorgfalt auf Viren gepr?ft.
> Jedoch ?bernehmen weder BITO-Lagertechnik Bittmann GmbH noch der Absender
> (Patrick Hoffmann) die Haftung f?r Viren; es obliegt Ihrer Verantwortung, die
> E-Mail und deren Anh?nge auf Viren zu pr?fen.
>
>
>
> This email is exclusively meant for the addressee and may contain
> confidential information or information which can be classified as
> professional secret. Any view or opinion stated in this email is that of the
> author and does not necessarily represent the view or the opinion of
> BITO-Lagertechnik Bittmann GmbH. If you are not the addressee and if this
> email has been transmitted to you by mistake, you may not make use of,
> publish, transmit, reproduce or print the information contained therein for
> whatever purpose. We take every reasonable care to check all out-bound emails
> for viruses. However, neither BITO-Lagertechnik Bittmann GmbH nor the sender
> (Patrick Hoffmann) can be held liable for the occurrence of viruses and any
> consequential damages. It is therefore the addressee's sole responsibility to
> check incoming emails and attachments for viruses.
>
>
>
> Anh?nge - :
>
> Versand am 18.06.2014 11:55 von Patrick Hoffmann
>
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
>
> Devel mailing list
>
> [email protected]<mailto:[email protected]>
>
> http://mailman.owncloud.org/mailman/listinfo/devel
>
>
>
>
> _______________________________________________
> Devel mailing list
> [email protected]
> http://mailman.owncloud.org/mailman/listinfo/devel
_______________________________________________
Devel mailing list
[email protected]
http://mailman.owncloud.org/mailman/listinfo/devel