最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jqTransform Update Select Options - Stack Overflow

programmeradmin1浏览0评论

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 pletely.

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

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 pletely.

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

Share Improve this question asked Aug 11, 2011 at 20:19 Brad WilkieBrad Wilkie 3315 silver badges12 bronze badges
Add a ment  | 

5 Answers 5

Reset to default 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 ment this line:

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

And then, after "onchange" event run:

$('#container select').jqTransSelect();
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.

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

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

regarding this:

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

When you ment 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.

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();
发布评论

评论列表(0)

  1. 暂无评论