Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jqTransform Select - Ajax Update?

I'm using the jqTransform plugin to style my form elements, which has led to a slight problem with my select boxes. It appears the select box is hidden and replaced by a custom DIV containing a list, etc.

I've managed to get the plugin firing the select's click event when something is selected from the list, but I'm having a little trouble updating the visual list - it appears the plugin doesn't support ajax update out of the box.

Does anyone have experience of performing ajax updates on selects transformed by jqTransform?

Transformed select looks something like:

<div class="jqTransformSelectWrapper" style="z-index: 8; width: 63px; ">
<div>
<span style="width: 62px; ">Petrol</span><a href="#" class="jqTransformSelectOpen"></a>         </div>
<ul style="width: 63px; height: 24px; overflow-x: hidden; overflow-y: hidden; display: none; visibility: visible; ">
<li><a href="#" index="0" class="selected">Petrol</a></li></ul>
<select id="fuel_type_id" name="fuel_type[id]" class="jqTransformHidden" style=""><option value="1">Petrol</option></select>
</div>

The plugin won't transform an already transformed select (you can force it to by removing the jqTransformHidden class, but that just duplicates the visible select).

I wonder if there's some clever jquery I could use to return the select to it's former state and then perform the transform again?

Thanks,

Paul

like image 232
Paul Avatar asked Jan 17 '12 19:01

Paul


1 Answers

following did it for me:

function fix_select(selector) {
    var i=$(selector).parent().find('div,ul').remove().css('zIndex');
    $(selector).unwrap().removeClass('jqTransformHidden').jqTransSelect();
    $(selector).parent().css('zIndex', i);
}
fix_select('select#my_updated_select_box');
like image 57
Teodor Todorov Avatar answered Oct 16 '22 02:10

Teodor Todorov