Hi,

I installed the jQuery update module but unfortunately the preview of file attachments is no longer working. When clicking the preview button the button bar where you can choose Flash| Preview | Image etc. appears but not the preview of the file itself (see attached screenshot). If you click the link in the button bar then the file node opens and there the the preview is working as well.

Any idea?
Thank you for support!
Filburt

Comments

miglius’s picture

Can you post a reference to the jQuery update module you're using?

filburt’s picture

I use version jQuery Update 6.x-2.x which updates Drupal to jQuery 1.3.x (currently 1.3.2)...

(I would need it for the Gallery Assist Lightboxes module - some of the integrated Lightboxes, like Colorbox or preetyPhoto need jQuery 1.3)

Thanks a lot and greetings, Filburt

phayes’s picture

There is likely more than one place where jQuery 1.3 breaks, one place is at file_form.js line 7

It was
$('input[@type=file]').change(function() {

It should be
$('input[type=file]').change(function() {

Just remove the @. This should be done regardless of your jquery version ( The @ is depreciated as of 1.2, but was removed in 1.3)

miglius’s picture

Does this change fixes the issue above?

mrangryfish’s picture

I just had this problem and found the solution the hard way. And was about to report this fix but found it was already logged here. So this is more google-able here is the error you get if you dont remove the @ symbol:

this is the error in the browser - uncaught exception: Syntax error, unrecognized expression: [@type=file]

This came up for me when I was trying to use 'hierarchical select content taxonomy' and was getting a "You don't have Javascript enabled" error message from it. The problem i suppose was instead that this error prevented more js from continuing.

Is there harm in pushing this fix into the next release? Might save some people an hour or so of hunting around.

brianV’s picture

Title: File attachment preview does not work with jQuery 1.3 (jQuery update module) » Remove deprecated '@' sign / fix file attachment preview in jQuery 1.3
Status: Active » Needs review
StatusFileSize
new792 bytes

Patch attached to remove the deprecated '@' sign. Just to clarify, this symbol is deprecated in the version of jQuery (1.2.6) that ships with D6, and is removed in jQuery 1.3.2, which ships with jQuery Update 6.x-2.x.

Note that this doesn't make everything work, just removes a single incompatible element.

Equinger’s picture

I just want to confirm that file previews on the page do not display with the jquery update mentioned above even with this patch.

brianV’s picture

Status: Needs review » Needs work

Yep, the above patch was intended as a starting point, not a complete solution.

Equinger’s picture

Thanks, Brian. I think this might be the other problem. The file preview, from what I understand, relies on the Drupal AHAH call as seen in file.inc:

function file_render_preview_for($file, $handler, $id) {
$form['preview'] = array(
'#type' => 'button',
'#id' => $handler .'-'. $id,
'#ahah' => array(
'path' => 'file_preview/'. $handler .'/'. file_get_hash($file->uri) .'/'. $file->vid,
'wrapper' => 'file-preview-container-'. $id,
'method' => 'replace',
'effect' => 'slide',
),
);

form_expand_ahah($form['preview']);
return $form;
}

I think the Jquery update module needs to be fixed or we need a workaround here:

http://drupal.org/node/796538#comment-3784102

Unfortunately I need this version of Jquery update.

Equinger’s picture

Any new thoughts here. I'm still having problems viewing previews. I am pretty certain that it is related to this jquery update.

jvieille’s picture

Previews nor node title population by the selected file name work with Jquety Update module enabled

jvieille’s picture

6 solves the node title population by the selected file name issue, but not preview
I tried
http://drupal.org/node/806500#comment-4004316
and
http://drupal.org/node/806500#comment-3744998

but it did not help
One and a half year issue - any hope for a solution?

jvieille’s picture

+1

jvieille’s picture

Has anyone found a solution?

Something here, but this did not help in my case
http://drupal.org/node/806500#comment-5076470

johanneshahn’s picture

Status: Needs work » Closed (works as designed)

try using jquery_update 6.x-1.1
this is more an jquery_update problem.

jvieille’s picture

Title: Remove deprecated '@' sign / fix file attachment preview in jQuery 1.3 » JQuery compatibility: Attachement previews and autoload do not work
Priority: Normal » Major
Status: Closed (works as designed) » Active

No, it is a FF compatibility issue with latest versions of JQuery
It is major issue, one of my biggest concerns as it breaks the magic of auto loading previews

jvieille’s picture

Title: JQuery compatibility: Attachement previews and autoload do not work » JQuery > 1.2.6 : Attachement previews and autoload do not work

The JQuery changes for 1.3 version are here
http://docs.jquery.com/Release:jQuery_1.3

Something to look at:

For autoload previews:
in file.theme.inc


function theme_file_previews($data)
...

    if (FILE_HANDLER_AUTOLOAD) {
      drupal_add_js('$(document).ready(function() { $(\'#'. $handler_first .'-'. $id .'\').trigger(\'mousedown\'); });', 'inline');
    }
..

changes where made to .trigger()
http://api.jquery.com/trigger/
that might affect this construct.
Actually, the

for the preview section is created, but empty then using 1.3.2

in file_attach.theme.inc
function theme_file_attachments($files, $pid)

Probably the js code generated might need some tweeks to get through latest jscript?

johanneshahn’s picture

dear jvieille,
ur right with the change of trigger handler in jq 1.3
this will solve the problem of first loaded handler.

but the main problem is that with jquery_update the preview ajax requests
didnt work at all.

the issue on jquery_update does not fix it for fileframework.
http://drupal.org/node/806500

i would rewrite the complete preview think with a small own solution ($.ajax()....).
we had similar problems with third party modules like bitcache etc.
my plan is to remove much as possible of this dependencies.

what u think?

jvieille’s picture

Title: JQuery > 1.2.6 : Attachement previews and autoload do not work » JQuery 1.3+ : Attachement previews and autoload do not work
Assigned: filburt » Unassigned

Some firebug debugging of the file node preview

This is the code that is generated by the theme_file_previews function

$(document).ready(function() { $('#file-preview-0 .file-preview-toggle').each(function() { $(this).mousedown(function() { $('#file-preview-0 .file-preview-toggle').each(function() { $(this).removeClass("active"); }); $(this).addClass("active"); }); }); });
$(document).ready(function() { $('#file-preview-0').append(' | <a href="/" id="file-preview-hide-0" >hide</a>'); });
$(document).ready(function() { $('#file-preview-hide-0').click(function() { $('#file-preview-0 .file-preview-toggle').each(function() { $(this).removeClass("active"); }); $('#file-preview-container-0').html(''); return false; }); });
$(document).ready(function() { $('#file_video_flash_swf-0').trigger('mousedown'); });

it is followed by

$(document).ready(function() { $('a.file-tip').cluetip(); $('a.file-thickbox').click(function () { $('.file-links').hide(); }); });
tb_pathToImage="\u002Fsites\u002Fall\u002Fmodules\u002Ffileframework\u002Fjquery\u002Fthickbox\u002FloadingAnimation.gif";

With JQuery 1.2.6, the html output is:

<div id="file-preview-container-0">
  <div style="display: block;">
    <div class="file-video">
      <object height="565" width="400" data="/bitcache/8209b6ce4544f48b5316e65547f6d290f21a58c3?vid=423" type="application/x-shockwave-flash">
        <param value="/bitcache/8209b6ce4544f48b5316e65547f6d290f21a58c3?vid=423" name="movie">
        <p>Your browser is unable to display this multimedia content.</p>
      </object>
      <p> <small> Problems viewing the video? <a class="ext" href="http://www.adobe.com/products/flashplayer">Download the latest Adobe Flash Player »</a> <span class="ext"></span> </small> </p>
  </div>
</div>

With JQuery 1.3.2, it becomes
<div id="file-preview-container-0"></div>

I can't do much more investigating this issue.
Help would be much appreciated: Previews are one of the smartest features of FF it really need to work with JQuery 1.3+ that is necessary for many modules.

johanneshahn’s picture

Status: Active » Closed (fixed)

try out latest dev version.

please wait foor latest nightbuild 2011-Feb-26

jvieille’s picture

Status: Closed (fixed) » Active

The latest dev does not help.
Have you changed something that might let you think the issue is solved?

Why this quote "please wait foor latest nightbuild 2011-Feb-26"

Thanks for looking at this issue.

johanneshahn’s picture

hi jvieille,
u can checkout the latest dev version via git

git clone --branch master johanneshahn@git.drupal.org:project/fileframework.git

on drupal.org u can download the new version if drupal updates the commits from git.
this happens mostly at midnight. then a downloadable tar/zip is created.

so if u need the latest dev please update fileframework via git or wait until 2011-Feb-26
2011-Dec-06

my fault:
i think its better to close fixes if module tar is generated by drupal.

jvieille’s picture

Not sure I get it.

- There is a new dev on the project page, dated of today
- "2011-Feb-26" Are you sure? this is almost last year...

I am not yet comfortable with git...

johanneshahn’s picture

copy paste error
mean 2011-Dec-06

jvieille’s picture

Status: Active » Closed (fixed)

Today's dev is the good one...
THANK YOU SO MUCH!!!!!!