Skip to content

Define $formfield when mediaHandler fires instead of closure - #382

Closed
augustuswm wants to merge 1 commit into
CMB2:trunkfrom
augustuswm:trunk
Closed

Define $formfield when mediaHandler fires instead of closure#382
augustuswm wants to merge 1 commit into
CMB2:trunkfrom
augustuswm:trunk

Conversation

@augustuswm

Copy link
Copy Markdown

cmb.mediaHandlers.* are redefined on the first click of each “file” or “file_list” on the page. Each time .list and .single are redefined the local variables for the current “file” and “file_list” are closed over. This breaks the handlers for any previously clicked “files” and “file_lists”. Variables have been moved into the handlers themselves rather than rewriting the handlers.

It might be more elegant to define new handlers for each "file" or "file_list" that still use the closure over $formfield in particular as opposed to the approach here.

In reference to issues: #250, #296

cmb.mediaHandlers.* are redefined on the first click of each “file” or
“file_list” on the page. Each time .list and .single are redefined the
local variables for the current “file” and “file_list” are closed over.
This breaks the handlers for any previously clicked “files” and
“file_lists”. Variables have been moved into the handlers themselves
rather than rewriting the handlers.
In reference to :CMB2#250,
CMB2#296
@augustuswm

Copy link
Copy Markdown
Author

Following up to see if there is anything I can do to assist in getting either this fix added or implementing a fix for the issues in another way.

@jtsternberg

Copy link
Copy Markdown
Member

@augustuswm sounds like you have a good handle on a possible solution. Would you be willing to submit a PR?

@jtsternberg

Copy link
Copy Markdown
Member

Wow, that's embarrassing.. just realized this IS a PR. ha ha.. I think I have it sorted though.

@jtsternberg

Copy link
Copy Markdown
Member

These commits should take care of the issue: 6db15bd...730ef08 (note: I gave you props since you reported and submitted a fix)

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@augustuswm@jtsternberg