jQuery Plugins » pass https://jqueryplugins.info jQuery plugins, tutorials and resources Tue, 18 Oct 2011 17:13:24 +0000 en hourly 1 http://wordpress.org/?v=3.2.1 getJSON wont allow array to pass through https://jqueryplugins.info/2011/10/getjson-wont-allow-array-to-pass-through/ https://jqueryplugins.info/2011/10/getjson-wont-allow-array-to-pass-through/#comments Sun, 16 Oct 2011 08:13:32 +0000 Admin https://jqueryplugins.info/2011/10/getjson-wont-allow-array-to-pass-through/ Post link: getJSON wont allow array to pass through

function near_home(lat,long,miles) { var url = "api_url"; var places = []; $ .getJSON(url, function(data) { $ .each(data['results'], function(i, place) { places.push(place); }); console.log(places); }); console.log(places); return places; } So the...

]]>
Post link: getJSON wont allow array to pass through

function near_home(lat,long,miles) {
  var url = "api_url";
  var places = [];

  $  .getJSON(url, function(data) {
    $  .each(data['results'], function(i, place) {
      places.push(place);
    });
    console.log(places);
  });
  console.log(places);
  return places;
}

So the first console.log() will return the desired objects. But the second console method results in null data. I’ve rewritten this thing a few times over and can’t seem to find reason for this madness. What am I missing?

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/getjson-wont-allow-array-to-pass-through/feed/ 0
Why won’t the variable pass JQUERY? https://jqueryplugins.info/2011/10/why-wont-the-variable-pass-jquery/ https://jqueryplugins.info/2011/10/why-wont-the-variable-pass-jquery/#comments Sun, 16 Oct 2011 02:14:46 +0000 Admin https://jqueryplugins.info/2011/10/why-wont-the-variable-pass-jquery/ Post link: Why won’t the variable pass JQUERY?

My code: $ ('.colorPick').click(function(e) { var x = e.pageX - this.offsetLeft; var y = e.pageY - this.offsetTop; var canvas2 = this.getContext('2d'); var data = canvas2.getImageData(x, y, 1, 1).data; var rgb...

]]>
Post link: Why won’t the variable pass JQUERY?

My code:

$  ('.colorPick').click(function(e) {
var x = e.pageX - this.offsetLeft;
var y = e.pageY - this.offsetTop;
var canvas2 = this.getContext('2d');
var data = canvas2.getImageData(x, y, 1, 1).data;
var rgb = 'rgb(' + data[0] + ',' + data[1] + ',' + data[2] + ')';
$  ('.colorPicker').each(function(rgb) {
    var x = this.width;
    var y = this.height;
    var canvas1 = this.getContext('2d');
    gradient1 = canvas1.createLinearGradient(0, 0, x, y);
    gradient1.addColorStop(0, 'rgb(255, 255, 255)');
    gradient1.addColorStop(0.5, rgb);
    gradient1.addColorStop(1, 'rgb(0, 0, 0)');
    canvas1.fillStyle = gradient1;
    canvas1.fillRect(0, 0, x, y);
});
}).disableSelection();

The variable rgb will not pass to the next .each function?

I am new to this if the answer is simple

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/why-wont-the-variable-pass-jquery/feed/ 0
How to pass a form input value into a javascript function https://jqueryplugins.info/2011/10/how-to-pass-a-form-input-value-into-a-javascript-function/ https://jqueryplugins.info/2011/10/how-to-pass-a-form-input-value-into-a-javascript-function/#comments Mon, 10 Oct 2011 18:21:36 +0000 Admin https://jqueryplugins.info/2011/10/how-to-pass-a-form-input-value-into-a-javascript-function/ Post link: How to pass a form input value into a javascript function

I have a generic javascript function which takes one parameter function foo(val) { ...} and I want to call the function when submit a form <form> <input type="text" id="formValueId"/> <input...

]]>
Post link: How to pass a form input value into a javascript function

I have a generic javascript function which takes one parameter

function foo(val) { ...}

and I want to call the function when submit a form

<form>
<input type="text" id="formValueId"/>
<input type="button" onclick="foo(this.formValueId)"/>
</form>

but the expression foo(this.formValueId) does not work (not surprised, it was a desperate attempt), So the question is that, how can I pass a form value to the javascript function.
As I mentioned the javascript is generic and I don’t want to manipulate the form inside it!

I could create a helper function in the middle to get the form values with jquery (for example) and then call the function but I was wondering if I can do it without the helper function

thanks

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/how-to-pass-a-form-input-value-into-a-javascript-function/feed/ 0
How to Pass Parameter to funcCall in Jquery Validation https://jqueryplugins.info/2011/10/how-to-pass-parameter-to-funccall-in-jquery-validation/ https://jqueryplugins.info/2011/10/how-to-pass-parameter-to-funccall-in-jquery-validation/#comments Fri, 07 Oct 2011 09:16:50 +0000 Admin https://jqueryplugins.info/2011/10/how-to-pass-parameter-to-funccall-in-jquery-validation/ Post link: How to Pass Parameter to funcCall in Jquery Validation

I have to pass an extra parameter to funcCall method. How to do that? And What is the use of i in the parameter? E.g: myFuncCallMethod(fields,i,rules,options) newest questions tagged jquery...

]]>
Post link: How to Pass Parameter to funcCall in Jquery Validation

I have to pass an extra parameter to funcCall method. How to do that? And What is the use of i in the parameter?
E.g: myFuncCallMethod(fields,i,rules,options)

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/how-to-pass-parameter-to-funccall-in-jquery-validation/feed/ 0
How to pass jQuery to eval’d code? https://jqueryplugins.info/2011/10/how-to-pass-jquery-to-evald-code/ https://jqueryplugins.info/2011/10/how-to-pass-jquery-to-evald-code/#comments Thu, 06 Oct 2011 22:15:39 +0000 Admin https://jqueryplugins.info/2011/10/how-to-pass-jquery-to-evald-code/ Post link: How to pass jQuery to eval’d code?

First, check out my fiddle fiddle jsFiddle is nice, but sometimes it runs a bit slow, so I made this simple pure JS fiddle (can be ran locally) Working great...

]]>
Post link: How to pass jQuery to eval’d code?

First, check out my fiddle fiddle

jsFiddle is nice, but sometimes it runs a bit slow, so I made this simple pure JS fiddle (can be ran locally)

Working great so far, but I want to be able to use jQuery in my fiddle. Type alert(typeof $ ); in the bottom left box and press “Run” to see what I mean (says undefined).

So how do I pass jQuery off to the iframe and give it the correct context? I suspect I could set doc.contentWindow.$ =$ or something like that, but I still need to give the correct context so it knows where to find the elements. How would I do that?

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/how-to-pass-jquery-to-evald-code/feed/ 0
Jquery iframe with Modal Window pass parameter https://jqueryplugins.info/2011/10/jquery-iframe-with-modal-window-pass-parameter/ https://jqueryplugins.info/2011/10/jquery-iframe-with-modal-window-pass-parameter/#comments Thu, 06 Oct 2011 15:14:22 +0000 Admin https://jqueryplugins.info/2011/10/jquery-iframe-with-modal-window-pass-parameter/ Post link: Jquery iframe with Modal Window pass parameter

Hello I have a problem when I modify the input of a iframe that is open with SimpleModalWindow Plugin. I have the code: $ ("#imgTab").click(function(){ $ ("#iframeNode").contents().find("input[name='objParent']").val('val1'); $ ("#modalWindow").modal({ opacity:80,...

]]>
Post link: Jquery iframe with Modal Window pass parameter

Hello I have a problem when I modify the input of a iframe that is open with SimpleModalWindow Plugin.

I have the code:

 $  ("#imgTab").click(function(){
    $  ("#iframeNode").contents().find("input[name='objParent']").val('val1');
    $  ("#modalWindow").modal({
    opacity:80,
    overlayCss: {backgroundColor:"#fff"}
    });
});

the iframe is in a div

    <div id="modalWindow" style="display:none;background-color:#FFFFFF">
    <iframe src="biblioteca.php" height="600px" width="900px" id="iframeNode" name="iframeNode"></iframe>
</div>

And the element to modify into the iframe is:

<input type="text" name="objParent" id="objParent"/>

Thanks.

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/jquery-iframe-with-modal-window-pass-parameter/feed/ 0
jQuery.ajax is hitting the url of a previous call, no matter which url I pass to it https://jqueryplugins.info/2011/09/jquery-ajax-is-hitting-the-url-of-a-previous-call-no-matter-which-url-i-pass-to-it/ https://jqueryplugins.info/2011/09/jquery-ajax-is-hitting-the-url-of-a-previous-call-no-matter-which-url-i-pass-to-it/#comments Tue, 27 Sep 2011 22:13:43 +0000 Admin https://jqueryplugins.info/2011/09/jquery-ajax-is-hitting-the-url-of-a-previous-call-no-matter-which-url-i-pass-to-it/ Post link: jQuery.ajax is hitting the url of a previous call, no matter which url I pass to it

The following call should try to hit “/getSomething”. However, it’s hitting “/previousSomething”, a url fetched previously via jQuery.ajax. I see the request to the old url go out, however neither...

]]>
Post link: jQuery.ajax is hitting the url of a previous call, no matter which url I pass to it

The following call should try to hit “/getSomething”. However, it’s hitting “/previousSomething”, a url fetched previously via jQuery.ajax. I see the request to the old url go out, however neither the “success” nor the “failure” function is getting called.

jQuery.ajax("/getSomething", {
  success: function(cartData){
    alert("success")
    movieCart = cartData;
    callback(cartData);
  },
  failure: function(){
    alert("failure");
  }
});

This code is running on a nasty corporate site which loads of scripts written by who-knows, multiple versions of jquery imported, etc. I suspect this is a problem called by the generally messy ecosystem my code is running in. Anybody have ideas about specifically what might be going on, or how to fix or even troubleshoot it?

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/09/jquery-ajax-is-hitting-the-url-of-a-previous-call-no-matter-which-url-i-pass-to-it/feed/ 0
jQuery > How to pass the value of a select list to an onclick handler? https://jqueryplugins.info/2011/09/jquery-how-to-pass-the-value-of-a-select-list-to-an-onclick-handler/ https://jqueryplugins.info/2011/09/jquery-how-to-pass-the-value-of-a-select-list-to-an-onclick-handler/#comments Sun, 18 Sep 2011 20:15:07 +0000 Admin https://jqueryplugins.info/2011/09/jquery-how-to-pass-the-value-of-a-select-list-to-an-onclick-handler/ Post link: jQuery > How to pass the value of a select list to an onclick handler?

I have a button element below in which I need to make the “template” variable dynamic to match the val() property of the currently selected item in the “template” select...

]]>
Post link: jQuery > How to pass the value of a select list to an onclick handler?

I have a button element below in which I need to make the “template” variable dynamic to match the val() property of the currently selected item in the “template” select menu. How can I do this?

<select id="template">..select options</select>

<button
type="button"
id="myButton"
onclick="window.open('<?php echo $  thePath ?>/test.php?template=?????', 'popup');
return false;">
click me
</button>

I know I can grab the selected option in jQuery with $ (‘#template :selected’).val();

How can I pass this to the onclick handler?

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/09/jquery-how-to-pass-the-value-of-a-select-list-to-an-onclick-handler/feed/ 0
How would I pass data to an external script loaded with $.getScript()? https://jqueryplugins.info/2011/09/how-would-i-pass-data-to-an-external-script-loaded-with-getscript/ https://jqueryplugins.info/2011/09/how-would-i-pass-data-to-an-external-script-loaded-with-getscript/#comments Fri, 16 Sep 2011 05:15:14 +0000 Admin https://jqueryplugins.info/2011/09/how-would-i-pass-data-to-an-external-script-loaded-with-getscript/ Post link: How would I pass data to an external script loaded with $.getScript()?

So I’m trying to load a javascript remotely using jquery’s $ .getScript, but I’m puzzled on how I can pass data to the external script. I’ve tried setting variables before...

]]>
Post link: How would I pass data to an external script loaded with $.getScript()?

So I’m trying to load a javascript remotely using jquery’s $ .getScript, but I’m puzzled on how I can pass data to the external script.

I’ve tried setting variables before the call but they aren’t available in the script that gets loaded, and when I try to send/retrieve them using the query string, the remote script tries to read the querystring of the base file that it gets called from, not itself. Is there any other way to do this? Or is it possible to have a javascript file read its own querystring rather than the file it’s called from (that’s loaded in the browser)?

// editor ini
var editor_ini = { page: current_page, action: 'edit' };
var foo = 'bar';
// load the editor
$  .getScript('assets/desktop/desklets/'+launcher.config.editor+'/execute.js', function(){});

In the execute.js file, the editor_ini and foo are both unavailable, I get the same result with:

// load the editor
$  .getScript('assets/desktop/desklets/'+launcher.config.editor+'/execute.js', { page: current_page, action: 'edit', foo: 'bar' }, function(){});

because the remote script seems to be getting the query string from the original document rather than the one used when calling the file.

If it matters, I was trying to use the query object plugin for jquery for reading the query string.

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/09/how-would-i-pass-data-to-an-external-script-loaded-with-getscript/feed/ 0
How to pass an array through in JQuery Ajax and how to concieve it in server side? https://jqueryplugins.info/2011/09/how-to-pass-an-array-through-in-jquery-ajax-and-how-to-concieve-it-in-server-side/ https://jqueryplugins.info/2011/09/how-to-pass-an-array-through-in-jquery-ajax-and-how-to-concieve-it-in-server-side/#comments Mon, 12 Sep 2011 10:13:29 +0000 Admin https://jqueryplugins.info/2011/09/how-to-pass-an-array-through-in-jquery-ajax-and-how-to-concieve-it-in-server-side/ Post link: How to pass an array through in JQuery Ajax and how to concieve it in server side?

I have a problem where i have to pass a list of ids to serverside to delete some users, but my requirement is to do it using JQuery Ajax. But...

]]>
Post link: How to pass an array through in JQuery Ajax and how to concieve it in server side?

I have a problem where i have to pass a list of ids to serverside to delete some users, but my requirement is to do it using JQuery Ajax. But I was not able to get the parameters in my server side can anybody give a help on this to sort out pls?

What i have done till now is shown below

  var idList = new Array();
$  (document).ready(function () {
    $  ('input:checkbox').click(function () {
        //set our checkedcount variable to 0
        var checkedCount = 0;
        //loop through and count the number of "checked" boxes
        $  ('.acceptUsers:checked').each(function () {
            //if a checked box was found, increase checkedCount by 1
            idList.push($  (this).val());
            checkedCount++;
        });
    });
});
      $  ('#btnDelete').click(function () {
          url = 'Teacher/UpdateUserStatus/';
          var ids = idList.toString();
          $  .ajax({
              type: "POST",
              url: url,
              data: { 'userIds': ids },
              contentType: "application/json; charset=utf-8",
              dataType: "html",
              success: function (data) {
                  alert('yeah');
                }
              }
          });
      });

What i have done in my server side is

    [HttpPost]
    public JsonResult UpdateUserStatus(object userIds)
    {
        List<int> usersToDelete = new JavaScriptSerializer().ConvertToType<List<int>>(userIds);
        this.userService.DeleteUsers(usersToDelete);
        return Json(true, JsonRequestBehavior.AllowGet);
    }

Can anybody know why my server side method is not calling?

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/09/how-to-pass-an-array-through-in-jquery-ajax-and-how-to-concieve-it-in-server-side/feed/ 0