N
N
Nikita Sklyuev2012-02-04 08:54:29
JavaScript
Nikita Sklyuev, 2012-02-04 08:54:29

Partial JavaScript work

Hello dear habrahumans.
Faced such a nuisance, made 1 of the clients a new design for the admin panel of the self-written engine. I used Twitter Bootstrap for this. I checked it in all browsers, everything works fine, but the client calls and says that a number of functions do not work, I naturally quickly check, everything works for me again, the client sends a video where the functions described by him really do not work.
But switching tabs (tabs from the Bottstrap box) does not work, and the following code construction does not work: Moreover, the donkey does not throw any errors at all. I checked it on similar browsers on my computer, everything works with a bang. And modal windows and Bootstrap work fine on the client. It turns out that half of the functionality disappears somewhere.

$("input[name=cat]").live("click", function(){
if($(this).is(":checked")){
$("select[name=cat]").attr({"disabled":"disabled"});
}else{
$("select[name=cat]").removeAttr("disabled");
}
});



Apparently the client has some kind of restrictions, or something cuts JS.

Now you need to go to the client to see what's wrong on his computer, but I would like to go with specific thoughts on how this can be fixed.

Please tell me what could be the problem?

PSOS Windows 7, IE9, Kaspersky Anti-Virus!

Answer the question

In order to leave comments, you need to log in

17 answer(s)
L
lashtal, 2012-02-04
@lashtal

crooked adblock rules eating something?

S
Silver_Clash, 2012-02-04
@Silver_Clash

Try $('select[name="cat"]').
Turn on js error output and see what the browser writes.

N
Nikita Sklyuev, 2012-02-04
@trilodi

It's just that this code works in a similar donkey, only on a different computer. okay, if you can still experiment here, then what about the bootstrip tabs?

S
Silver_Clash, 2012-02-04
@Silver_Clash

In general, instead of input[name=cat] it is better to refer to the element by id (I hope you have one).
This construction is also very interesting: .attr({"disabled":"disabled"});
For some reason, I always thought that it should be: .attr("disabled","disabled") ( jQuery .attr ).

N
Nikita Sklyuev, 2012-02-04
@trilodi

The element is not 1 so using id won't work.
and attr({"disabled":"disabled"}); I use it out of habit when I add a lot of attributes.

A
altrosilka, 2012-02-04
@altrosilka

There was a similar problem. It helped me once, I don’t remember the essence, to be honest.
$('select[name=cat]').attr({'disabled':'disabled'}); => $('select[name=cat]').attr({'disabled':''});

N
Nikita Sklyuev, 2012-02-04
@trilodi

Me now not so much the $('select[name=cat]').attr({'disabled':'disabled'}); worries how many non-working tabs. I still somehow can get around the select, but tabs are a disaster!

M
MT, 2012-02-04
@MTonly

I would try temporarily disabling Kaspersky Anti-Virus.
By the way, it makes sense to refer to form elements like this:
form.elements['cat']

D
Dmitry Tallmange, 2012-02-05
@p00h

Is your js code (specifically bootstrap) being minified? Perhaps going to one js file with other scripts?

D
Dmitry Tallmange, 2012-02-05
@p00h

Look at the problem live, of course, it is impossible?

N
Nikita Sklyuev, 2012-02-05
@trilodi

bootstrap version v1.4.0

N
Nikita Sklyuev, 2012-02-05
@trilodi

Here is all the js used on the page:

N
Nikita Sklyuev, 2012-02-05
@trilodi

$(document).ready(function(){
$('.tabs').tabs();
$("form.editorV").live("submit", function(){
var _id=$(this).attr("id");
$("#"+_id+" button").button('loading');
$.ajax({
type: 'POST',
action: "http://payservice.uz/admin.php?cont=vauch",
url: "http://payservice.uz/admin.php?cont=vauch",
dataType: 'html',
async: true,
timeout: 15000,
data: {
ajax: 'update_vaucher',
cat: ($("#"+_id+" .catterc").is(':checked')?$("#"+_id+" .catterc").val():$("#"+_id+" .catter option:selected").attr("value")),
id: $("#"+_id+" input[name=vauchid]").val(),
pin: $("#"+_id+" textarea[name=pin]").val(),
numinal: $("#"+_id+" input[name=numinal]").val(),
usd: $("#"+_id+" input[name=usd]").val(),
descr: $("#"+_id+" textarea[name=descr]").val(),
status: $("#"+_id+" select[name=status]").val(),
date: $("#"+_id+" input[name=date]").val()
},
success: function(data){
$("#"+_id+" button").button('complete');
$("#"+_id+" input[name=cat]").val(($("#"+_id+" input[name=cat]").is(':checked')?$("#"+_id+" input[name=cat]").val():$("#"+_id+" select[name=cat] option:selected").attr("value")));
$("#"+_id+" .cata").text(($("#"+_id+" input[name=cat]").is(':checked')?$("#"+_id+" input[name=cat]").val():$("#"+_id+" select[name=cat] option:selected").attr("value")));
}
});
return false;
});
$(".modal").on("hidden",function(){
var _idsM=$(this).attr("id");
$("#"+_idsM+" button").button('reset');
$("input[name=cat]").attr({"checked":"checked"});
});
$("select[name=cat] option:first").attr({"selected":"selected"});
$(".modal").on("show", function(){
var mID=$(this).attr("id");
$('#'+mID+" .catterc").live("click", function(){
if($('#'+mID+" .catterc").is(":checked")){
$('#'+mID+" .catter").attr({"disabled":"disabled"});
}else{
$('#'+mID+" .catter").removeAttr("disabled");
}
});
});
});

N
Nikita Sklyuev, 2012-02-05
@trilodi

Line wrapping in the code was made by habraparser!

D
Dmitry Tallmange, 2012-02-05
@p00h

According to your code: as an option, replace .attr() with .prop()
Regarding the client. Be sure to run the code on another browser to exclude or confirm the participation of the system / anti-virus in this atrocity

N
Nikita Sklyuev, 2012-02-05
@trilodi

So I'm talking about, of everything it doesn't work as it should only: $('.tabs').tabs();

N
Nikita Sklyuev, 2012-02-06
@trilodi

As it turned out, all this is created by KIS. I had to add the site to the exception

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question