Jump to content

[jquery] how to modify code to function


AndyPSV

Recommended Posts

jQuery(function($) {
    $('.<% $r.id %><% if $r.id_to <> '' %>_<% $r.id_to %><% /if %>_').click(function() {
        $('.<% $r.id %><% if $r.id_to <> '' %>_<% $r.id_to %><% /if %>').toggle();
    });
    $('.comment_<% $r.id %><% if $r.id_to <> '' %>_<% $r.id_to %><% /if %>_').click(function() {
        $('.<% $r.id %><% if $r.id_to <> '' %>_<% $r.id_to %><% /if %>').show();
        $('#comment_<% $r.id %><% if $r.id_to <> '' %>_<% $r.id_to %><% /if %>').focus();
    });
});

 

please leave the variables (I've purposely left them, because its the problem)

 

function(id.......

Link to comment
https://forums.phpfreaks.com/topic/252884-jquery-how-to-modify-code-to-function/
Share on other sites

ok, I've did it

 

function toggleCommentBox(id,id_to) {
		$('.'+id+id_to+'_').click(function() {
			$('.'+id+id_to+'').toggle();
		});
		$('.comment_'+id+id_to+'_').click(function() {
			$('.'+id+id_to+'').show();
			$('#comment_'+id+id_to+'').focus();
		});
	}

jQuery(function() {
						toggleCommentBox('<% $r.id %>','<% if $r.id_to <> '' %>_<% $r.id_to %><% /if %>');
					});

 

my next problem is, when I've got

 

$('.'+id+id_to+'').show();

it needs to stay like this?

 

because for example, if I use

 

$('.'+id+id_to).show();

 

IT DON'T WORKS

+ how to deal with such thing:

 

function viewAllComments(id,id_to) {
	$('#view_all_c'+id+id_to+'_').click(function() {
		$('#view_all_c'+id+id_to+'').empty().html('<div class="comment" style="padding-left:10px"><img src="<% $TPL %>i/ico/loader.gif" style="margin-top:6px" alt=""/></div>');
		$('#view_all_c'+id+id_to+'').load('<% $URL %>/c/[b]<% if $r.id_to == '' %>q<% else %>a<% /if %>/<% $r.id %>[/b]');
		$('#view_all_c'+id+id_to+'_Hide').hide();
	});
}

 

 

<% if $r.id_to == '' %>q<% else %>a<% /if %>/<% $r.id %>, id -> <% $r.id %>; id_to -> <% $r.id_to %>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.