I'm trying to use the Media Browser "View Library" tab on the "Select media" modal widget, and the submit button is not working. Every time I click, the modal redirects back to the homepage. The media is not added to the node. I have to refresh to get the modal to disappear, and afterward, due to the refresh, the media is still not present.

Steps to reproduce:

1. Click Select media.
2. Click to highlight a media object in the view.
3. Click Submit.
4. Redirects back to homepage.

At first I thought this was due to a conflict with my jQuery Update, which I hacked to use jQuery 1.7, for jQuery Mobile support, but I disabled jQuery Update, and the issue is still happening. I also cleared all caches, and am not using either JS or CSS aggregation.

I am using the Seven theme on the admin side, and a custom subtheme of AT Commerce (AdaptiveTheme subtheme) on the frontend, and am using the admin theme for content editing.

I can let you know modules & versions (as a txt attachment from drush) if that would be helpful.

CommentFileSizeAuthor
#9 select media error.png524.61 KBrickvug
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

EvanDonovan’s picture

Even though #1319528: Media browser view library exposed form submit problem is for 2.x, and also mentioned specifically when a filter is added, it appears that it may be a related issue.

joshmiller’s picture

I'm using 2.x and having the same issue. Frustrating because there is no way to connect a library item with a fieldable entity right now.

Dave Reid’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Dave Reid’s picture

Status: Active » Postponed (maintainer needs more info)

Has anyone checked their browser's JavaScript console log for any errors when they submitted? I haven't been able to reproduce this yet on 2.x

Dave Reid’s picture

victoriachan’s picture

Hi,

This is the error I got on the JS Console,
using Media 2.0-unstable3 (and with Views 3.0). I clicked on 'Select Media' on my node edit page, and then clicked on 'View Library' and selected an image, and clicked 'Submit'. This error occurred when I clicked 'Submit' and redirected the page in the modal to the site's homepage.

Error: this.contentWindow.Drupal.media is undefined
Source File: http://kf.local/sites/all/modules/media/js/media.popups.js?v=7.x
Line: 103

Could this be related to Views? I noticed that on the Media project page, under requirements, it states: Views (7.x-2.x only). And I recall reading in one of the duplicate tickets relating to this that it was something to do with Views.

I have tried with Views 7.x-3.0 and 7.x-3.1, and both had the problem. What version of Views are you trying it with, Dave Reid?

I understand that Media explicitly states that it only supports up to Views 2.x only. But Views 7.x-2.x seems to be unavailable for download anymore though I have the impression that I was using Views 2.x before and have only recently upgraded to 3.x for a security fix. I think I'll raise a separate issue regarding that description on the projects page, as it could confuse people.

Meanwhile wonder if that's what's causing this problem?

Thanks very much,
Victoria

victoriachan’s picture

Oops sorry, I was being silly. Someone's pointed out to me that the statement, 'Views (7.x-2.x only)', meant that Views was required on Media 7.x-2.x only. :P

Fanaile’s picture

I'm getting the same js error using File entity 7.x-2.0-unstable3, Media 7.x-2.0-unstable3 and Views 7x-3.1.

I also tried (just for curiosity's sake) to click on the "cancel" button, which does the same thing and creates the same js error as clicking on the submit button.

Line 103 of media.popups.js reads: if (this.contentWindow.Drupal.media.browser.selectedMedia.length > 0) {

But, as this is the exact same as what was in 7.x-1.0-rc3 (which I was using prior successfully) I'm not sure that it's actually being caused by the js?

rickvug’s picture

FileSize
524.61 KB

Is the redirect happening within the modal or outside of the modal? Attached is a screenshot of the error that I've been periodically experiencing with Media for quite a while now. I think this is it.

victoriachan’s picture

Yes, that looks like it. It was happening inside the modal for me too.

gmclelland’s picture

Maybe this is related http://drupal.org/node/1319528#comment-5605672 - try the ctools patch and see if it helps

ambientdrup’s picture

Did anyone get this to work? I'm also experiencing this same issue with the 3.x version of Views and the 7.x-2.0 version of Media.

-Trevor

gmclelland’s picture

Did you try the ctools patch from http://drupal.org/node/1324238#comment-5360410? See if it helps you.

ambientdrup’s picture

Haven't tried the patch yet. It's on my list.

-Trevor

ambientdrup’s picture

Ok I ran the patch and it seems to work. I can now select the View Library tab and then select an image and it inserts correctly.

So this looks like it works.

Now the question is how can we get that patch committed to CTools core? Is that possible?

-Trevor

gmclelland’s picture

Status: Postponed (maintainer needs more info) » Needs review

I think we need more people to test the ctools patch and see if it works for them. If it does work, I think we should report our results over to the ctools issue #1324238: Not all views exposed forms auto-submit correctly (was: Clean up and improve auto-submit.js0 so that it can be committed.

ambientdrup’s picture

Ok cool. Let me know how I can help to keep this process moving along rapidly.

Thanks!

-Trevor

heshanlk’s picture

cTools update didn't fix my issues and when I looked in to error console I can see

Error: this.contentWindow.Drupal.media is undefined
Source File: http://sitename/sites/all/modules/contrib/media/js/media.popups.js?v=7.x
Line: 103
gmclelland’s picture

drumla’s picture

I have the same problem: The Submit button redirects back to the homepage. The homepage is rendered inside the modal dialog box. The only way to close the modal box is to reload the page. No file gets selected into the content.

I'm using:
Drupal core 7.12, ctools 7.x-1.0-rc2, File entity 7.x-2.0-unstable3, Media 7.x-2.0-unstable3, Media: YouTube 7.x-1.0-beta3, Plupload integration 7.x-1.0-rc1 and Views 7.x-3.3.

If I'm understanding it right, the Ctools issue is fixed in ctools 7.x-1.0-rc2, but that does not help.
Has anyone made any progress in finding the source of this problem? If I can help by providing more information, please let me know.
- Stefan

vlajkop’s picture

Victoria, Stefan, Fanaile,

Have you been able to solve this issue? If yes please explain how. I have absolutely same error reported in line 103 of media.popups.js?v=7.x...

Modules are same as you are using.

victoriachan’s picture

Hi,

Actually I have just tried this again yesterday, disabling the other modules one by one to see what was causing the problem on my site, since I couldn't replicate this problem on a clean build. Guess what I found out?

It was actually my browser cache all along.

Well I suppose there was that problem with ctools, but after upgrading ctools to latest, I was still having the problem.

I guess the problem was due to my browser caching the old JavaScript files from Media 1.x or the old Ctools even after I have upgraded them. As I was just testing on my local site, I didn't have 'Aggregate JavaScript files' turned on, and so clearing Drupal cache didn't do anything to clear the old JavaScript.

Hope this helps!

Victoria

victoriachan’s picture

Can someone else confirm that this has been fixed for Media 2.x-dev / Media 2.0-unstable3 with the latest ctools (7.x-1.0) and views (7.x-3.3)?

If you are still having problems, try clearing your browser cache or test with a fresh browser.

If this is fixed, we can update the ticket status.

It works for me now with Media 2.0-unstable3, ctools (7.x-1.0) and views (7.x-3.3).

Cheers,
Victoria

vlajkop’s picture

Thanks for responding Victoria.

Everything seems to be ok with media module. Remotes stream wrapper module is one that I'm having issue with and its plug-in “Remote URL” that is causing same behavior as described here. Also with newest versions of this modules I'm not getting this plug-in “Remote URL” as option displayed.

Cache cleaning for browser didn't solve my issue with modules versions 7.x.1 and modal window redirecting to homepage on submit.

Just for making sure, I'm setting new virtual host on my testing machine with fresh drupal install with minimal module install and settings. I'll report back here about both issues.

Vlajko

And to confirm (UPDATE):
After installing fresh installation of drupal (http://www.acquia.com/downloads Acquia Drupal 7.12.13) and only next couple of modules:

Chaos tools 7.x-1.0 ; File entity 7.x-2.0-unstable3+21-dev ; Media7.x-2.0-unstable3 ; Media Field7.x-2.0-unstable3 ; Media Internet Sources7.x-2.0-unstable3 ; Views7.x-3.3

Everything seems to be working as expected and selecting images from library view for content types in field file using media selector widget works as expected.

johan.gant’s picture

Hi,

I can currently repeat this issue in:

  • Safari 5.x
  • Chrome + Chromium
  • IE 9

JS debug output is: Uncaught TypeError: Cannot read property 'browser' of undefined in media.popup.js, line 103

Interestingly, Firefox seems to work, although I did have to purge the cache before it worked.

I'm using media 7.x-2.0-unstable3, ctools 7.x-1.0 and views 7.x-3.3.

Thanks,
Johan

dddave’s picture

Status: Needs review » Postponed (maintainer needs more info)

Can this be confirmed against the latest dev?

Dave Reid’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
jhedstrom’s picture

I'm seeing this issue on a site using Media 2.x, and this js error is appearing when this happens:

Uncaught ReferenceError: namespace is not defined

From media.library.js, line 3.

jhedstrom’s picture

Latest dev version got rid of the js error reported in #28.

j0rd’s picture

For future discussion see this issue:
#1319528: Media browser view library exposed form submit problem

From what I can tell, that patch did not resolve the issue. I am running latest stable of CTools & Views. Recent -dev versions of file_entity & media

The problem with the patch from #1324238 is that, while it's discarding "enter" from "ajax submitting" the form, it's allowing it's default event to bubble up in the dom, and the default action for pressing enter in an input field on a form, is to submit the form.

Since this form's action is action="/", we end up with the homepage in the media browse popup dialog.

From debugging the CTools auto-submit.js, I don't see how it can solve this problem for anyone.

The CTools patch would need to check to see if e.keyCode === 13, then e.preventDefault(), or better yet, trigger the "AJAX submit". The problem is, while this makes sense for our needs with Media Browser Popup, I'm not sure if it makes sense for all other users of CTools.

So in our case, we might require preventingDefault() for all enters in our popup.

Does this problem still exist for other people?

Closing this issue as duplicate, as there's another one which is currently open and the maintainer can't duplicate this issue. So head over there and discuss.
#1319528: Media browser view library exposed form submit problem

Closing duplicate issue: