Showing posts with label JQuery. Show all posts
Showing posts with label JQuery. Show all posts

Wednesday, May 24, 2017

loading jquery in dev tools

sorry I lost where I got this from for the HT


var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// ... give time for script to load, then type (or see below for non wait option)
jQuery.noConflict();

Tuesday, August 9, 2016

add jquery to console script

var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);

Thursday, July 9, 2015

cache: false in $.ajax( calls

work because they add the following request header
  1. Cache-Control:
    no-cache

Wednesday, January 14, 2015

to select a particular forms elements in jquery

just use the form's id as one of the selectors

Add an action to a form with jquery

$("#blah").get(0).setAttribute('action', blahURL);

Monday, December 1, 2014

Passing jquery pattern

works because this works

(function (a) {alert(a);})("kl")


Wednesday, August 20, 2014

All and Bubbling

Using the all selector, you can bubble on events thusly: $('*').on('click', function () {

Monday, November 4, 2013

force jquery not to use cache

$.ajax({url: "url", success: Callback, cache: false});


and avoid http 304!

Tuesday, October 29, 2013

Including JQuery manually

<script src="<%= Url.Content("~/Scripts/jquery-1.5.1.min.js") %>" type="text/javascript

Use NuGet

to install JQuery in a project where it isn't already installed

Monday, October 28, 2013

Difference between 'POST' and $.post

in this case the the token was properly posted

$.post(serviceURL, {Ids: ids,actionId: action.Id, __RequestVerificationToken: token },
             function (data) {


while this way

$.ajax(
      {
            url: serviceURL,
             type: 'POST',
              contentType: "application/json; charset=utf-8",
            data: {
                    Ids: ids,
                   actionId: action.Id,
               __RequestVerificationToken: token

it wasn't. No idea why.

Wednesday, June 26, 2013

clear value of fileupload

$(this).replaceWith($(this).clone(true)); 

Wednesday, March 13, 2013

Multiple classes in css and jquery



.blah1.blah2 are treated differently
in css this is "or" in jquery this is "and"

Thursday, February 21, 2013

Testing CSS Properties When Inherited

testing with javascript is not helpful because it returns "inherit"
JQuery css function likewise returns "inherit"

I used the is function - that works properly

for e.g. $(this).is(":visible")

Friday, February 15, 2013

Checkboxlist in Chrome not rendering well

when the Checkboxlist  was in a div - the text was wrapping.

so I did this

   //////////////////////////////////////
            $('document').ready(function () {
                $(":input[id^=chkListblah_]").each(
                          function () {
                              $(this).get(0).parentElement.style.whiteSpace = "nowrap";
                            }
                    );
            });
          
            //////////////////////////////////////

Count of checkboxes in a checkboxlist object

since thisis rendered by asp.net as a table I thought a count of the cells would work.
it worked in IE but not Chrome

so I did this

$(":input[id^=chkListblah_]").length;

where the checkboxes id's were chkListblah_1, chkListblah_2 etc.

Tuesday, November 20, 2012

Monday, November 12, 2012

JQuery test for existance



if ($("#blah").length > 0) {


what confounds me  is the following failed



if ($("#blah ")[0].length > 0) {

just like JQuery will create an empty object with 0 length in case the object does not exist shouldn't it be referenced at [0]?