2

I'm just trying to change my formfields with jqtransform.

With the following Javascript Code, I added new formfields:

    <script type="text/javascript">
        $(function() {
            var scntDiv = $('#p_scents');
            var i = $('#p_scents p').size() + 1;

            $('#addScnt').live('click', function() {

                if(i < 4){
                    $('<p>\n\
                        <label for="p_scnts">\n\
                        <input type="text" id="p_scnt" size="17" name="fmac' + i +'[]" value="" />\n\
                        <select name="fmac' + i +'[]" size="1" id="p_scnt_a">\n\
                            <option selected value="K">KABEL</option>\n\
                            <option value="W">WLAN</option>\n\
                            <option value="V">VPN</option>\n\
                        </select>\n\
                        </label>\n\
                    </p>').appendTo(scntDiv);
                    i++;
                }

                if(i > 3 ){
                    $('#showaddmac').hide();
                }
                return false;
            });

            $('#remScnt').live('click', function() {
                if( i > 2 ) {
                        $(this).parents('p').remove();
                        i--;
                }
                if(i < 4 ){
                    $('#showaddmac').show();
                }
                return false;
            });
        });
    </script>

This works without problems, but the new fields will be not transformed. Does anyone know a solution to this problem?

Sorry for my bad english :)

teebot
  • 1,089
  • 2
  • 12
  • 25
user545782
  • 21
  • 2

2 Answers2

0

Presumably you would need to call jqtransform again after the element was created. I don't know if works with dynamically inserted items though.

William Hurst
  • 2,231
  • 5
  • 33
  • 54
0

You need to call jqTransform on the new element like this :

$("YOUR ELEMENT").jqTransform();
teebot
  • 1,089
  • 2
  • 12
  • 25