Need to perfect your website? Try these: google pagespeed
yslow
It's a great way to tweek your site for better browsing experiances for your users.
More tools to simplify and optimize your code:
google closure
yuicompressor
minify
Tuesday, May 14, 2013
Wednesday, May 8, 2013
jquery not firing
So I had this issue before where when a page loads the jquery script would not fire for other function displays like tabs.
Why is that?
Well there was one answer I had which was using .on() but this only fires when an event is triggered, like mouse clicks, etc. In this case it was in the jquery tabs. The script would show on the first tab but not show in the others.
What to do?
The task was in each tab there was a condition, and if met an image would display. Theoretically the condition should work for each tab (which is a mvc page view) but the issue was that the condion written was too general. So when it became more specific the code was then fired.
The condition took the first tag for the entire loaded view but not run each script for each pageview.
eg,
$("#A #B").addClass('something');
$("#C #B").addClass('something');
$("#D #B").addClass('something');
rather than
$("#B").addClass('something');
Why is that?
Well there was one answer I had which was using .on() but this only fires when an event is triggered, like mouse clicks, etc. In this case it was in the jquery tabs. The script would show on the first tab but not show in the others.
What to do?
The task was in each tab there was a condition, and if met an image would display. Theoretically the condition should work for each tab (which is a mvc page view) but the issue was that the condion written was too general. So when it became more specific the code was then fired.
The condition took the first tag for the entire loaded view but not run each script for each pageview.
eg,
$("#A #B").addClass('something');
$("#C #B").addClass('something');
$("#D #B").addClass('something');
rather than
$("#B").addClass('something');
Subscribe to:
Posts (Atom)