简体   繁体   中英

Dynamically Add in jQuery Mobile Attributes

I am adding in jQuery mobile attributes dynamically. I have had luck with some of them. However I can't seem to figure out how to add in data-type="horizontal" properly.

This code works perfectly:

$("form, fieldset, #info_list").collapsible();
$("#color_group, #animal_group").controlgroup();

I want #color_group & #animal_group to have the attribute data-type="horizontal". I couldn't find any methods like the ones for controlgroup & collapsible, though; so I tried this:

$("#color_group, #animal_group").attr("data-type", "horizontal");

This adds the attribute, however using this method jQuery mobile does nothing with it when it's added in this way.

DEMO

the controlgroup widget has a 'type' option you can set to horizontal ( http://api.jquerymobile.com/controlgroup/ )

$("#color_group, #animal_group").controlgroup({ type: "horizontal" });

Use .controlgroup({ type: "horizontal" }) or "vertical" to change type, not data-type .

$("controlgroup_ID").controlgroup({
    type: "horizontal"
});

$("controlgroup_ID").controlgroup({
    type: "vertical"
});

Demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM