Forum Replies Created
-
AuthorPosts
-
mattklParticipantOk. Outlook ate your response and spit it out kind of wonky, and you have it marked as private here, so I cannot see it the way you intended. From what I can decode in the email, I think setting the value is what you’re proposing. That’s ok, if you only want a single default color and if you’re not using the color picker in an add-more. In add-more fields, I have not been able to get default values to work. At all. Plus, I need several default colors available for my client. So, setting the default palettes is the best solution – for me, anyway.
mattklParticipantOMG. Nevermind. The update values needed quotes. How did I miss that? KMN.
mattklParticipantOk. I have a (temporary) fix. An ugly fix.
First, I determine if the user is on a mobile device (the list is not comprehensive) in the PHP above the Piklist field definitions in my metabox file and use that to set a boolean flag…
$draggable = TRUE; if( stristr($_SERVER['HTTP_USER_AGENT'],'ipad') ) { $draggable = FALSE; } else if( stristr($_SERVER['HTTP_USER_AGENT'],'iphone') || strstr($_SERVER['HTTP_USER_AGENT'],'iphone') ) { $draggable = FALSE; } else if( stristr($_SERVER['HTTP_USER_AGENT'],'blackberry') ) { $draggable = FALSE; } else if( stristr($_SERVER['HTTP_USER_AGENT'],'android') ) { $draggable = FALSE; }Then, for the add-more definitions, I altered the sortable parameter:
,'sortable' => $draggableAt the moment, this accomplishes the goal of keeping the sortable/dragable functionality for desktop and laptop devices, but disables it and allows for add-more field editing on mobile devices.
mattklParticipantProvided that the class of the remove elements is always ‘piklist-addmore-remove’, then this binds to all existing occurrences of the removal buttons, as well as any new occurrences of the removal buttons.
Further, it acts on all removal buttons in the page, regardless of which meta-box they are in. That may or may not be what others will want. In those cases, you would specify the meta-box ID or some container element to restrict this being added to only that specific group.
mattklParticipantActually, you don’t need the jQuery(document).ready part…
jQuery(document).on("click", ".piklist-addmore-remove", function (event) { return confirm("Are you sure you want to remove this item/section?"); });
mattklParticipantOk. Took me a beat to figure this out, since jquery is already in the admin section. You just have to replace $ with jQuery.
Here is what I am using. It works (so far) for me.
jQuery(document).ready(function () { jQuery(document).on("click", ".piklist-addmore-remove", function (event) { return confirm("Are you sure you want to remove this item/section?"); }); });
mattklParticipantI think that would work. Now I just have to figure out how to load jquery to the admin (post edit) area without breaking the meta-box.
-
AuthorPosts