나는 학교용으로 작은 응용 프로그램을 개발해야하고 처음에는 포토샵에서 조금 설계하여 html로 "변환"했습니다. 그게 다 괜찮 았어. 나는 자바 스크립트로 사용자 정의 드롭 다운을 만들었고 원활하게 작동했습니다. 방금 CodeIgniter를 디자인에 구현하려고 시도했지만 javascript가 두 번 실행되기 시작했습니다.자바 스크립트 두 번 실행
일반 HTML 버전의 코드와 codeigniter 결과를 비교해 보았지만 어떤 차이점도없는 것 같습니다.
나를 도와 줄 수 있습니까? Krof Drakula에 의해 질문으로 http://intellia.itforit.net/index.htm
여기에 코드의 가장 중요한 조각되어 있습니다 :
이실제 jQuery 플러그인 : (styleForm.js가)
;(function($){
$.fn.styleForm = function() {
var form = this;
/* Select */
$('select', this).each(function(){
var div = '<div class="styledSelect"><ul>';
var first = false;
$('option', this).each(function(){
var cssclass = "";
if(!first) {
first = true;
cssclass = 'class="first"'
}
div += '<li ' + cssclass + ' id="' + $(this).attr("value") + '">' + $(this).text() + '</li>';
});
div += '</ul></div>';
$(this).hide();
$(this).after(div);
});
$('.styledSelect ul').toggle(function(){
$('li:not(.first)', this).show("fast");
}, function(){
$('li:not(.first)', this).hide("fast");
});
$('.styledSelect ul li:not(.first):not(.selected)').click(function(){
var id = $(this).attr('id');
var content = $(this).text();
$('.styledSelect ul li.first').attr('id', id).text(content);
$('.styledSelect ul li').css({'font-weight': 'normal'});
$(this).css({'font-weight': 'bold'});
/* SELECT in Select form item */
var selected = $('select option[value="' + id + '"]:not(.first)', form).get(0);
selected.setAttribute("selected", "selected");
//$(form).submit();
});
};
})(jQuery);
그리고 여기이야 다음은 CodeIgniter의 결과입니다 그것은이 시작됩니다 : (canvasDrawing.js) 사전에
$(document).ready(function(){
$('form').styleForm();
//Unimportant canvas stuff
});
고맙습니다,,Duckness
효과가 있어도 고맙지 만! ;-) 그것이 이유라고 기대하지 않았다! – MCautreels