5

I'm dynamically altering a select list's options. I am using the jqTransform plugin. It won't update itself automatically, which I didn't expect it would, but I can find a method for updating the display. I can't even find a method for removing it completely.

What I'd like is to find a method such as formelement.jqTransformUpdate() that will fix this. Any ideas?

Brad Wilkie
  • 331
  • 4
  • 12

5 Answers5

3

I know it's an old question, but maybe it helps someone. I couldn't find the answer, so I looked into jqtransform.js code.

Just comment this line:

if($select.hasClass('jqTransformHidden')) {return;}

And then, after "onchange" event run:

$('#container select').jqTransSelect();
Code Maverick
  • 20,171
  • 12
  • 62
  • 114
c3nt
  • 46
  • 2
  • 1
    That adds another drop-down to the page every time I call it now... doesn't transform the existing one. – mpen Nov 24 '12 at 19:32
1
function selectRating(rating) {
   $("#ratingModal .jqTransformSelectWrapper ul li a").each(function() {
     if (parseInt($(this).attr("index")) == rating - 1) {
         $(this).click();
     }
   });      
}

A JS function I used in my own application to select specific option with the given rating. I think you can modify it to meet your needs.

The idea is to use a.click event handler to select specific option in the transformed select list.

user851126
  • 61
  • 1
  • 2
0

regarding this:

That adds another drop-down to the page every time I call it now

When you comment this line:

if($select.hasClass('jqTransformHidden')) {return;}

add this just below:

if($select.hasClass('jqTransformHidden')) $select.parent().removeClass();

it's not a very elegant solution, but it worked in my case, the new select is still nested inside child and so on but it's working fine.

Natan Streppel
  • 5,759
  • 6
  • 35
  • 43
Szymon Nowak
  • 23
  • 1
  • 5
0

It could be better, try to add new method in jqtransform.js:

$.fn.jqTransSelectRefresh = function(){
    return this.each(function(index){
        var $select = $(this);

        var i=$select.parent().find('div,ul').remove().css('zIndex');
        $select.unwrap().removeClass('jqTransformHidden').jqTransSelect();
        $select.parent().css('zIndex', i);

    });
}

after that, just call it each time you need to refresh the dropdown:

$('#my_select').jqTransSelectRefresh();
Fischer Tirado
  • 321
  • 3
  • 5
0

hi please try the following to selectively reapply styling to newly created or select box returned from the ajax request

$('#container select').jqTransSelect();

kannetkeifer
  • 734
  • 1
  • 6
  • 11