[jQuery] jQuery Functions

2009-11-10 Thread Digital Evasion
Firstly hello everyone and apologies for breaking new ground in terms
of simple idiot questions.
Ok so I'm trouble doing something I would consider as simple with
jquery.
I have a form and i want to run a common function (that checks a bunch
of inputs) that will be run when certain fields blur. working off the
blur field is not a problem, but parsing the function is... example
below. Looking at callback's in jQuery I'm still a bit confused and i
cannot find anything floating around the net that does similar to what
i want to do (common function invoked from multiple different fields).

function EvalFields() {
  var arrFieldNames = array;
  var boolFields = boolean;
  boolFields = true;
  alert(running); // easy way to know if your running the code
or not
  arrFieldNames[0] = #frmField1;
  arrFieldNames[1] = #frmField2;
  arrFieldNames[2] = #frmField3;
  arrFieldNames[3] = #frmField4;
  arrFieldNames[4] = #frmField5;
  for (var x=0;xarrFieldNames.length;x++) {
if( !$.(arrFieldNames[x]).empty() ){
  boolFields = false;
}
  }
  if (boolFields == true) {
$.(#frmHiddenField).val(1);
  } else {
$.(#frmHiddenField).val(0);
  }
   }

^^ this is the function I want to use. It just cycles through a bunch
of fields and if they all have content it'll flick a switch for server
side processing later on.

$(#frmField1).blur(function () {
  EvalFields();
});
$(#frmField2).blur(function () {
  EvalFields();
});
$(#frmField3).blur(function () {
  EvalFields();
});
$(#frmField4).blur(function () {
  EvalFields();
});
$(#frmField5).blur(function () {
  EvalFields();
});
^^ the on blur events should be fine right?

I'm assuming that I'm not defining the function properly and/or
passing jquery through(maybe i'm not event getting this far!)...

The whole point of this was to not write the exact same code for the 5
odd, specific, blur events but i've wasted so much time on this i need
to seek assistance.

Can anyone help me with this? Thanks in advance.

p.s. all form elements have appropriate id's set, etc. and I'm
successfully using the Validation plugin already.


[jQuery] Re: Change image attribute based on variable

2009-02-26 Thread digital

Thank you very much.

It took me another hour but I managed to debug the code and get it all
working, thanks again.

On Feb 25, 7:38 pm, Stephan Veigl stephan.ve...@gmail.com wrote:
 Hi,

 instead of doing a complicate string handling you could simply use
 window.location.hash:

 $finalurl = window.location.hash;

 For debugging I would do it step by step and not all in one line:

 var el = $($finalurl+ :first);
 var src = el.attr(src);
 var src_split = src.split(.);
 var new_src = src_split.join(_on.);
 el.attr(src, new_src);

 This way you can use firebug to step through your code and see which
 statement produces the error.

 by(e)
 Stephan

 2009/2/25 digital michael.digital.b...@googlemail.com:



  Hi, pulling my hair out here.

  When the page loads I'm collecting a variable from the url which
  corresponds to the class of an image. I want to then change the image
  source. I'm doing this because the page doesn't reload and the menu
  needs to respond to the content if you get my meaning.

  $url = location.href;
  $hashtag = $url.search(/#/)
  $url2 = $url.split(#, $hashtag);
  $finalurl = $url2[1];

  This is the code I use to get the class name. When I try to add
  $finalurl to the attr (see below) it throws an error (undefined,
  console.log shows it is defined within the if statement).

  $($finalurl).attr(src, $($finalurl).attr(src).split(.).join
  (_on.));

  Full code:

  $url = location.href;
  $hashtag = $url.search(/#/)
  $url2 = $url.split(#, $hashtag);
  $finalurl = $url2[1];

  counttemp = 0;

  if (counttemp == 0) {
         console.log($finalurl);
         $($finalurl).attr(src, $($finalurl).attr(src).split(.).join
  (_on.));
         counttemp = countemp + 1;
  }

  Any help would be greatly appreciated.


[jQuery] Re: Change image attribute based on variable

2009-02-26 Thread digital

Thanks, I ended up playing around with the url before I passed it into
the function, didn't realise I could do it like that.

On Feb 25, 7:49 pm, brian bally.z...@gmail.com wrote:
 Also, $($finalurl) likely won't select anything because you're only
 passing the classname. It needs to be in the form '.classname'
 (prepended by a dot). Try $('.'+$finalurl)

 On Wed, Feb 25, 2009 at 2:38 PM, Stephan Veigl stephan.ve...@gmail.com 
 wrote:

  Hi,

  instead of doing a complicate string handling you could simply use
  window.location.hash:

  $finalurl = window.location.hash;

  For debugging I would do it step by step and not all in one line:

  var el = $($finalurl+ :first);
  var src = el.attr(src);
  var src_split = src.split(.);
  var new_src = src_split.join(_on.);
  el.attr(src, new_src);

  This way you can use firebug to step through your code and see which
  statement produces the error.

  by(e)
  Stephan

  2009/2/25 digital michael.digital.b...@googlemail.com:

  Hi, pulling my hair out here.

  When the page loads I'm collecting a variable from the url which
  corresponds to the class of an image. I want to then change the image
  source. I'm doing this because the page doesn't reload and the menu
  needs to respond to the content if you get my meaning.

  $url = location.href;
  $hashtag = $url.search(/#/)
  $url2 = $url.split(#, $hashtag);
  $finalurl = $url2[1];

  This is the code I use to get the class name. When I try to add
  $finalurl to the attr (see below) it throws an error (undefined,
  console.log shows it is defined within the if statement).

  $($finalurl).attr(src, $($finalurl).attr(src).split(.).join
  (_on.));

  Full code:

  $url = location.href;
  $hashtag = $url.search(/#/)
  $url2 = $url.split(#, $hashtag);
  $finalurl = $url2[1];

  counttemp = 0;

  if (counttemp == 0) {
         console.log($finalurl);
         $($finalurl).attr(src, $($finalurl).attr(src).split(.).join
  (_on.));
         counttemp = countemp + 1;
  }

  Any help would be greatly appreciated.


[jQuery] Change image attribute based on variable

2009-02-25 Thread digital

Hi, pulling my hair out here.

When the page loads I'm collecting a variable from the url which
corresponds to the class of an image. I want to then change the image
source. I'm doing this because the page doesn't reload and the menu
needs to respond to the content if you get my meaning.

$url = location.href;
$hashtag = $url.search(/#/)
$url2 = $url.split(#, $hashtag);
$finalurl = $url2[1];

This is the code I use to get the class name. When I try to add
$finalurl to the attr (see below) it throws an error (undefined,
console.log shows it is defined within the if statement).

$($finalurl).attr(src, $($finalurl).attr(src).split(.).join
(_on.));

Full code:

$url = location.href;
$hashtag = $url.search(/#/)
$url2 = $url.split(#, $hashtag);
$finalurl = $url2[1];

counttemp = 0;

if (counttemp == 0) {
console.log($finalurl);
$($finalurl).attr(src, $($finalurl).attr(src).split(.).join
(_on.));
counttemp = countemp + 1;
}

Any help would be greatly appreciated.


[jQuery] Re: Ignoring field within whole DIV

2007-09-30 Thread Digital Spaghetti

Sorry, I posted the wrong bit of code.  My .ajaxLoad code is:

$pastemonkey('#content').not($pastemonkey('#PasteTags')
[0]).ajaxStart(function(){
$pastemonkey.blockUI();
});

On Sep 30, 4:57 pm, Tane Piper [EMAIL PROTECTED]
wrote:
 Hi there,

 I am running into a little problem, I cannot seem to get my code to
 work to ignore 1 field inside a DIV.  I have a .ajaxLoad() on the div,
 that fires block UI when the content of the DIV changes, however also
 inside the DIV I have a field that has a autocomplete attached to it.
 When I type in this field, it fires the .ajaxLoad() and the block UI.

 My code is below:

 $pastemonkey('#PasteTags').livequery(function(){
 $pastemonkey(this).autocomplete('/tags/find/', {multiple: 
 true,
 matchContains: true});
 });

 $pastemonkey is my own var for $ using .noConflict.  I've tried using
 :not but couldn't get it to work.  Can anyone help?

 --
 Tane Piperhttp://digitalspaghetti.me.uk

 This email is: [ ] blogable [ x ] ask first [ ] private



[jQuery] Re: Problem with AJAX and links

2007-04-17 Thread digital spaghetti


Bahh, I've found a bug.  In the code when I get type, I check to see
if type == whatever.  But it seems if my links have more than 1
class, it fails.  For example my code may have a
href=/admin/posts/add class=add admin-linkAdd Post/a - this is
ignored.

Whats the best way to check to see if a link contains the class,
without doing a == selection on it?

Tane

On 4/17/07, digital spaghetti [EMAIL PROTECTED] wrote:

Hi Sean,

Thanks, that seems to have done the trick - although it broke the Tabs
plugin I was using in my admin interface.  I've created a workaround
and this works perfectly:

function hijackLinks(root) {
 $('a',root).click(function(){
var type = $(this).attr('class');
if (type == admin-link) {
// If admin link, load into sub-admin area
$('.admin-area').load(this.href,function(){
hijackLinks($('.content')); });
return false;
} else if (type == no-ajax) {
// If no ajax link, ignore
} else {
// Normal content area link
$('.content').load(this.href,function(){
hijackLinks($('.content')); });
return false;
}
});
}

$(document).ready(function() {
   hijackLinks(document);
});



Tane

On 4/17/07, Sean Catchpole [EMAIL PROTECTED] wrote:

 Hi Tane,

  function hijackLinks(root) {
  $('a',root).bind('click', function(){
 $('.content').load(this.href);
 return false;
  });
  };

 I would change this function to this instead of doing all that ajaxStart/Stop:
 function hijackLinks(root) {
   $('a',root).click(function(){
 $('.content').load(this.href,function(){
   hijackLinks($('.content')); });
 return false; });
 }

 Then you only need to run your: $(function(){ hijackLinks(document); }

 ~Sean




[jQuery] Problem with AJAX and links

2007-04-16 Thread digital spaghetti


Hey folks,

I've been working on this one with a little help, but i'm now stuck.

I have an AJAX interface, where I want all internal links to load
content into a specific div called .content.  The issue is it works,
except for link in content thats loaded into the div.

So far, here is what I have:

function hijackLinks(root) {
$('a',root).bind('click', function(){
  $('.content').load(this.href);
  return false;
});
};

This is the function that I pass the clicked link in to, I take it's
href and load the page into the .content div.

$(document).ready(function() {
  hijackLinks(document);
});

This loads the function on first load.  Then I do this:

$().ajaxStart(function(){
$.blockUI
hijackLinks($('.content').get(0));
});

$().ajaxStop(function(){
$.unblockUI;
hijackLinks($('.content').get(0));
});

i've called the function on both ajaxStart() and ajaxStop() to reload
the function into the page, but doesn't seem to work.  Can anyone
maybe help?

THanks,
Tane


[jQuery] Webrocket: My new jQuery-powered CMS

2007-04-14 Thread digital spaghetti


Hey folks,

Bit of a shameless plug here, but I'd like to announce to you my
project - Webrocket.  It's a CMS built on CakePHP, and using jQuery
for all it's JavaScript.  Currently it uses AJAX functions to load
most of the pages.  I've currently been working on this for a work
project, however the source code is being released under a MIT/GPL
Dual licence.

It also uses the Forms plugin, blockUI plugin and Tablesorter.  You
can check out a demo at http://66.160.135.85/

The official project page is at https://cakeforge.org/projects/webrocket/

Please note, this is an early alpha, as such the code is messy and
buggy.  Most statements are inline, however I will be changing that to
core functions in the next week.

Please feel free to comment, and if anyone feels like contributing
code please feel free to contact me.

Finally the site blog is at http://webrocket.wordpress.com

Tane Piper