[jQuery] Jquery + ExtJS 3.0

2009-08-23 Thread Mik Fig

Has anyone had any luck integrating Jquery and ExtJS 3.0?
I downloaded the ExtJS 3.0 SDK and I have a page where I am trying to
test out there grid functionality. So I included these javascript files:
ext-all.js and ext-jquery-adapter.js

I have taken a look in the Jquery documentation at the page

Tutorials:Using Ext With jQuery

For one thing I couldn't find jquery-plugins.js with the ExtJS SDK,
but i figured that since im using version 3.0 versus the 1.0.1 that is
used in this tutorial that this was all in ext-jquery-adapter.js.

But anyways, when I include ext-all.js, Firebug gives me this error:
Ext is not defined

I am including these javascript files in the middle of the body tag
inside of a div, so I'm not sure if this could also possibly be a
cause of the problem.

Any help would be appreciated,
Thanks,
Mikael


[jQuery] Re: Issue with setting click event functions in a for loop

2009-05-17 Thread Mik Fig
what i decided to do is unroll the loop, for example:

if you have this loop:

for(var i = 0; i = 9; ++i) alert(i);

then you could unroll it to this:

alert(0);
alert(1);
alert(2);
...
alert(9);

since i only had a total of 9 iterations of the loop, then it would only add
a little bit to filesize
but even then I will end up packing the js file when all is fully functional
later, so that then becomes not really and issue either

thanks though,
mikfig

On Sat, May 16, 2009 at 9:22 PM, mkmanning michaell...@gmail.com wrote:


 You might want to doublecheck that when you click the elements you
 took out of the loop, you really get what you say. Given your example,
 if you click #page2 it should alert 'page3' also.

 You don't really need the loop to attach the click and get at the
 number if it's part of the id:

 $('div[id^=page]').click(function(){
  console.log('page ' + this.id.replace(/page/,'') + ' clicked.');
 });

 Try Googling global variables, scope, and closures in JavaScript.


 On May 16, 2:16 pm, mikfig mikfi...@gmail.com wrote:
  I have a webpage that searches a database using a php script to search
  the database and a jQuery app on the page to retrieve the results and
  show them. So it works fine, but then I want to add page number
  buttons to allow the user to go to different pages of the results.
  So I have a DIV with the id of page_buttons and I use the following
  code:http://pastebin.com/m3dffbf99
 
  I use the offset and the results per page like this in a MySQL query
  in the php script: SELECT  LIMIT offset,
  resultsPerPage by the way.
 
  So anyways, the problem I am having is that if I have a loop like
  this:
 
  var pageNum = 6;
  ...
  for(var i = 0; i = pageNum; ++i)
  {
  $(#page + i).click(function() { alert('page ' + i + '
  clicked.'); });
 
  }
 
  The elements with IDs of page1, page2,... are buttons, and I
  tested the above loop. What happens is if I click any of the buttons
  with IDs of page1, page2,.. then they all alert with the string
  page 7 clicked. All the page buttons 1-6 display the string page 7
  clicked.
 
  To try to greater understand this problem I took the functionality out
  of the loop like this:
 
  var i = 2;
  $(#page + i).click(function() { alert('page ' + i + '
  clicked.'); });
  i = 3;
  $(#page + i).click(function() { alert('page ' + i + '
  clicked.'); });
 
  and it worked just fine with page2 alerting page 2 clicked and
  page3 alerting with page 3 clicked.
 
  So I was hoping someone could help me in explaining why this issue
  occurs and if there was a better way to do what I'm trying to do.
 
  Thanks,
  mikfig




-- 
DX for life