Как вызвать собственную функцию в jquery?

Доброй ночи,



Подскажите, пожалуйста, каким образом возможно вызвать эту функцию:

<pre><code class="javascript">$(function (){
	var r = Raphael('map', 1200, 820),
		attributes = {
            fill: 'url(http://.../js/img/colornone.png)',
            stroke: 'none',
            'stroke-width': 1,
            'stroke-linejoin': 'round'
        },
		arr = new Array();
	
	for (var shop in paths) {
		
		var obj = r.path(paths[shop].path);
		
		obj.attr(attributes);
		
		arr[obj.id] = shop;
		
		obj
		.hover(function(){
			this.animate({
				fill: 'url(http://.../js/img/colorhover.png)'
			});
		}, function(){
			this.animate({
				fill: attributes.fill
			});
		})
		.click(function(){
			
			document.location.hash = arr[this.id];
			
			var point = this.getBBox(0);
			
			$('#map').next('.point').remove();
			
			$('#map').after($('&lt;div /&gt;').addClass('point'));
			
			$('.point')
			.prepend($('&lt;a /&gt;').attr('href', paths[arr[this.id]].url).addClass('mapmoreinfo').text('Подробнее'))
			.prepend($('&lt;div&gt;').addClass('mapcontacts').text(paths[arr[this.id]].phone))
			.prepend($('&lt;div&gt;').addClass('mapinfo').text(paths[arr[this.id]].text))
			.prepend($('&lt;div&gt;').addClass('mapname').text(paths[arr[this.id]].name))
			.fadeIn();
			
			
		});
	
	}	
});








В данном коде:



<pre><code class="php">    $(document).ready(function(){
$('#ButId1').click(function() {
    $('.block-2').css(&quot;display&quot;, &quot;none&quot;);
    $('.block-1').show();
    $('#ButId1').css(&quot;background&quot;,&quot;#FFCC00&quot;);
    $('#ButId2').css(&quot;background&quot;,&quot;white&quot;);
    $('#ButId3').css(&quot;background&quot;,&quot;white&quot;);
    $('.block-3').css(&quot;display&quot;, &quot;none&quot;);
          
});

$('#ButId2').click(function() {
    $('.block-1').css(&quot;display&quot;, &quot;none&quot;);
    $('.block-2').show();
    $('#ButId1').css(&quot;background&quot;,&quot;white&quot;);
    $('#ButId2').css(&quot;background&quot;,&quot;#FFCC00&quot;);
    $('#ButId3').css(&quot;background&quot;,&quot;white&quot;);
    $('.block-3').css(&quot;display&quot;, &quot;none&quot;);

	/* Вызвать функцию необходимо здесь */

});

$('#ButId3').click(function() {

    $('.block-1').css(&quot;display&quot;, &quot;none&quot;);
    $('#ButId1').css(&quot;background&quot;,&quot;white&quot;);
    $('#ButId2').css(&quot;background&quot;,&quot;white&quot;);
    $('#ButId3').css(&quot;background&quot;,&quot;#FFCC00&quot;);
    $('.block-3').show();
    $('.block-2').css(&quot;display&quot;, &quot;none&quot;);
});
    });




Код находится в разных файлах, которые вызываются в документе (сначала верхний код, служащий для вывода карты, второй код для переключения между этажами). Перезагрузки на странице нет. Ajax не используется.



Подключены:

Библиотека jquery 1.7.1;

Библиотека Raphael;



Гугл, к сожалению, не помог — не знаю, что вводить в запросе
  • Вопрос задан
  • 35660 просмотров
Пригласить эксперта
Ответы на вопрос 1
BupycNet
@BupycNet
Основатель PushAll
Поменяйте начало
$(function (){
на
function fname(){
а также
}); на }
А потом вызывайте в нужном месте
fname();
т.к. у вас там $(document).ready(function(){ то обработка произойдет после того как все JS будут подгружены.
Удачи.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы