WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#29017 closed defect (bug) (worksforme)

[playlist], [audio] and [video] via AJAX don't work in 4.0-beta2 (but work in 3.9.1)

Reported by: Looimaster Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.0
Component: Media Keywords:
Focuses: Cc:

Description

In WordPress 3.9.1 I was able to get playlist/audio/video output via AJAX (with do_shortcode()) and initialize it like that:

jQuery('.wp-playlist').each(function(){
	return new WPPlaylistView({ el: this });
});

With [audio] and [video] I called $(this).mediaelementplayer(); instead.

Here's the execution flow copied from Chrome's Console (4.0-beta2-20140723):

Uncaught TypeError: Cannot read property 'replace' of undefined underscore.min.js?ver=1.6.0:1
x.template underscore.min.js?ver=1.6.0:1
(anonymous function) wp-util.js?ver=4.0-beta2-20140723:27
Backbone.View.extend.renderCurrent wp-playlist.js?ver=4.0-beta2-20140723:87
Backbone.View.extend.initialize wp-playlist.js?ver=4.0-beta2-20140723:21
b.View backbone.min.js?ver=1.1.2:1
d backbone.min.js?ver=1.1.2:1
(anonymous function) myfile.js?ver=1.0:23
m.extend.each jquery.js?ver=1.11.1:2
m.fn.m.each jquery.js?ver=1.11.1:2
$.ajax.success myfile.js?ver=1.0:22
j jquery.js?ver=1.11.1:2
k.fireWith jquery.js?ver=1.11.1:2
x jquery.js?ver=1.11.1:4
b jquery.js?ver=1.11.1:4

Change History (6)

#1 @celloexpressions
6 years ago

  • Component changed from General to Media
  • Milestone changed from Awaiting Review to 4.0

Moving to 4.0 for investigation.

#2 @wonderboymusic
6 years ago

  • Milestone 4.0 deleted
  • Resolution set to worksforme
  • Status changed from new to closed

I have no idea what custom code you are calling, where, or how, but the shortcodes work as expected as for me.

If you can edit the shortcodes in the modal, "AJAX" works just fine.

#3 @Looimaster
6 years ago

  • Resolution worksforme deleted
  • Status changed from closed to reopened

The full code I'm using is above. It's only three lines. I do do_shortcode('[playlist]'); and run new WPPlaylistView({ el: this }); where this is the returned container with .wp-playlist class. This error still happens in 4.0-beta3-20140812. It does not happen in 3.9.1. I can load playlist with AJAX on the front-end and setup it with the above code in 3.9.1 but not in any 4.0 version.

I have two WordPresses installed (3.9.2 and 4.0-beta3) at this moment and the plugin that does this has the same code.

It's not possible to load playlists via AJAX on front-end. In Media Library there is no preview in "Insert from URL" either (on front-end).

Last edited 6 years ago by Looimaster (previous) (diff)

#4 @ocean90
6 years ago

  • Milestone set to 4.0

and the plugin that does this has the same code.

Can you please share the plugin public?

#5 @Looimaster
6 years ago

  • Resolution set to worksforme
  • Status changed from reopened to closed

I tried that prepare a reduced test case and I got this error: Uncaught ReferenceError: WPPlaylistView is not defined instead of the error I mentioned earlier. I just found wp_playlist_scripts('audio'); and wp_playlist_scripts('video'); and when I add that to the plugin it starts working in 4.0-beta3 too. In 3.9.1 it works without these two functions.

So, this ticket can be closed. It's resolved.

#6 @DrewAPicture
6 years ago

  • Milestone 4.0 deleted
Note: See TracTickets for help on using tickets.