Microformats in Venddor IO

Introduction to Microformats

In Venddor IO, a microformat isn't just a CSS style; it's a strategic method for specifying JavaScript actions based on certain events tied to an HTML element. These microformats are essential for enhancing web page interactivity and user experience.

Understanding Microformats in Venddor IO

Microformats in Venddor IO adhere to a naming pattern: cm-new-microformat-name. The prefix cm- symbolizes it as a Venddor IO specific microformat. Interestingly, unlike traditional CSS styles, the details of a microformat are found in JavaScript files rather than CSS files. To locate the JavaScript code responsible for a specific microformat, one should search for the substring .hasClass('cm-microformat-name') within the /js/ directory.

Forms and Field Validation

Forms are vital for user inputs, and ensuring that these inputs are valid is crucial for smooth operations. Venddor IO makes this process streamlined with field validation microformats.

For instance:

<label class="cm-email cm-required" for="elm_id">Field name:</label>
<input type="text" name="test" value="Y" id="elm_id" />

The label element, associated with the element being validated using the for parameter, is pivotal for the field validator. The microformat for field validation is specified in the label element's class attribute, and these classes are combinable.

The label's descriptor is crucial as it gets used in error messages for incorrect input. Such messages can contain placeholders, including:

Some essential field validation microformats include:

JavaScript Integrations for Form Validations

In Venddor IO, certain JavaScript functions are crafted to define and validate specific patterns, like zip codes:

<script type="text/javascript">
Tygh.$.ceFormValidator('setZipcode', {
    US: {
        regexp: /^(\d{5})(-\d{4})?$/,
        format: '01342 (01342-5678)'
    },
    ...
});
</script>

Diverse Microformats for Field Validations

Several microformats are at developers' disposal to ensure data integrity and user-friendly input validations:

Additionally, custom validations can be achieved using the cm-regexp microformat:

<script type="text/javascript">
Tygh.$.ceFormValidator('setRegexp', {
    'elm_id': {
        regexp: "^[A-Za-z]+$",
        message: "Please, use only alphabetical signs"
    }
};
</script>

Enhanced Form Processing

Venddor IO offers enhanced interactivity with forms using specific microformats:

Events can also be defined for more granular control before and after form submission:

$.ceEvent('on', 'ce.formpre_add_to_cart_form', function(form, elm) {
  // Custom code
});

More Form Enhancements

Form Reload and Efficient Pickers

Triggering Form Submissions with Non-Traditional Elements

cm-submit: Assigning this to an element (other than submit buttons) submits its parent form upon a click.

Implementation: Ensure the element has the cm-submit microformat, provide the target dispatch in data-ca-dispatch, and optionally, if the element isn't within the form, specify the target form in data-ca-target-form.

Form Submission Window Control

Advanced Element Combinations

For complex interactivities:

Enhancing Combos and Tabs

In Venddor IO, the cm-combinations microformat facilitates the switching of various combos or sets, providing functionalities akin to expanding/collapsing sections or trees. The cm-js and cm-j-tabs microformats manage tabs, streamlining navigation within different sections of a form or page. With cm-save-state, users can preserve the state of specific containers, enabling a more personalized user experience.

Dynamic Node Cloning and Wrappers

Cloning nodes becomes a cinch with cm-first-sibling and cm-image-field. They're instrumental for operations like duplicating product options, each having its unique images.

The cm-hidden-wrapper microformat ensures elements are displayed only when they hold content. This helps in avoiding blank spaces or null elements on a page.

Harnessing AJAX for Dynamic Content Loading

Venddor IO taps into AJAX for real-time content updates. Microformats like cm-ajax, cm-comet, cm-ajax-cache, cm-ajax-force, and others manage AJAX requests, ensuring a fluid, live content experience without the need for page reloads.

With cm-reload, product content can dynamically update based on option changes, like price adjustments on variant selection.