Witajcie drodzy pehapowicze (IMG:
style_emoticons/default/smile.gif)
Raczkuję w temacie jQuery więc zwracam się do was z prośbą o pomoc.
Wymarzyło mi się, aby gdy użytkownik kliknie w ostatniego selecta by coś wklupać, zaraz pod nim wskoczy nowy select i tak w nieskończoność (IMG:
style_emoticons/default/smile.gif)
Znalazłem coś w interneciku i przerobiłem pod metodę focus(). Działa ale tylko na pierwszym selekcie (tak jakby ciągle stał na jednej wartości) Ma ktoś jakiś pomysł (IMG:
style_emoticons/default/questionmark.gif)
Kod
<div class="container">
<div class="row">
<input type="text" id="count" name="count" value="1" />
<div class="control-group" id="fields">
<label class="control-label" for="field1">Nice Multiple Form Fields</label>
<div class="controls" id="profs">
<div class="input-append">
<input autocomplete="off" class="span3" id="field1" name="prof1" type="text" placeholder="Type something (it has typeahead too)" data-provide="typeahead" data-items="8" data-source='["Aardvark","Beatlejuice","Capricorn","Deathmaul","Epic"]'/><button id="b1" class="btn btn-info add-more" type="button">+</button>
</div>
<br>
<small>Press + to add another form field :)</small>
</div>
</div>
</div>
</div>
<script src="http://code.jquery.com/jquery-1.9.0.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script>
<script>
$(document).ready(function(){
$
("#field"+next).focus
(function(e
){ e.preventDefault();
var addto
= "#field" + next; var newIn
= '<br /><br /><input autocomplete="off" class="span3" id="field' + next + '" name="field' + next + '" type="text" data-provide="typeahead" data-items="8">'; var newInput = $(newIn);
$(addto).after(newInput);
$
("#field" + next).attr
('data-source',$
(addto
).attr
('data-source')); });
});
</script>
Edit:
Późna pora, zapomniałem linka:
tu to działa (IMG:
style_emoticons/default/smile.gif)
http://jsbin.com/EBUMoKa/1/
Ten post edytował daggoth 20.01.2014, 23:38:52