Opened 11 years ago
Closed 11 years ago
#35181 closed defect (bug) (invalid)
Using Lodash makes media_upload dialog unable to use
| Reported by: | anhntbk08 | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Media | Version: | 4.4 |
| Severity: | normal | Keywords: | close |
| Cc: | Focuses: |
Description
I'm writing a plugin with Angular and Wordpress. When i declared https://lodash.com/ the media_upload is unable to use. Medias will be shown up but you can't Pick them and the 'select' event will not be fired.
There is no error on javascript.
var frame = wp.media.frames.file_frame = wp.media({
library: {
type: 'image'
},
frame: 'select',
multiple: true
});
frame.off('select');
frame.open();
// this won't be triggered
frame.on('select', function () {
If i remove lodash, everything is ok.
Thanks
Change History (2)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
WordPress uses Underscore.js for the media modal. It uses the same _ variable as Lodash.
You need to use Lodash's noConflict mode in your application to prevent it from overwriting the variable: