Jump to content

Recommended Posts

if you go here

http://zanedockery.com/p2

 

I can begin my question easier.

 

Click either button for Add New Customer or Builder

even use the Zip Code box and check it out....it should be working.

 

But what my main problem is...is with the Choose Builder dropdown.

This is the way it is supposed to act.

http://zanedockery.com/p2/index2.php

 

Now the only difference between these two examples (code wise) is that I am using AJAX ... the jQuery $.get function to get a list from the database.

 

What's bugging the living hell out of me is that whenever I do use $.get...like the first example page.  It doesn't register the clicks on the LIs

 

If you have firebug you'll notice things aren't working right.

 

Why can't I get my list and register their clicks?

 

Link to comment
https://forums.phpfreaks.com/topic/154579-solved-evil-innerhtml-using-jquery/
Share on other sites

Ok..still I find myself going back to Javascript (or jQuery..whatever).  I'm trying to get the Search to work on the keyUp event.  It works fine so far.  I can view all the matches and yada yada...doesn't look pretty yet but yeah...it works.

 

My only problem is the same problem I was having earlier.  If I use Javascript to edit the innerHTML of something.  I can't have any onClick triggered.  Mind you that I'm having them triggered via jQuery with

 

$('div.new').click(function() {
	$('#body').fadeTo('fast', .33);
	$('#popup').show();
});

 

On the page load the div click works just fine but when the search fails to yeild results...I have it show the two ONLY CLICKABLE divs and they aren't clickable.  Why?

 

check it out

http://zanedockery.com/p2

 

The Add New buttons are the click able ones

 

 

Using this

$('#searchterm').keyup(function(){
	$.post("get.php", {func: "getCustomers", s:$(this).val()}, function(data) {
		$('#content .results').html(data);											  
	});
});

 

I grab the customer list from the database using get.php

		$sql = "SELECT a.name, a.phone, CONCAT( a.address, ' ', b.city, ', ', b.state_prefix, ' ', a.zip ) AS address, c.builder as builder
				FROM customers a
				INNER JOIN zip_code b ON a.zip = b.zip_code
				LEFT OUTER JOIN builders c ON a.builder = c.id
				WHERE a.name LIKE '%$y%'
				ORDER by a.id DESC
		";
		$q = mysql_query($sql) or die(mysql_error());
		if(mysql_num_rows($q) >= 1) {
			while($r = mysql_fetch_array($q)) {
				$block .= "";
				$block .= "" . $r['name'] . "" . $r['builder'] . "";
				$block .= "
Phone: " . $r['phone'] . "";
				$block .= "\n";
			}
		}
	echo $block;

 

Works perfect....as far as getting the data and displaying it....

 

but when it is displayed I can't "click" on it.

 

If in the initial HTML I have a

some bull

and I write the following jQuery code

$('.result').click(function() {
	alert("Thou hast clickethed")
});

I can click it just fine, but if I populate the container for .result using jQuery like this

$('.result container').html("some bull")

 

then I can't "click" it....can I repeat myself anymore?

 

I don't understand what is going on with this. Does anyone else?

Woohoooo

 

after searching forever on the horrible documentation they have I found the live() function

 

 

so now instead of this...

   $('.result').click(function() {
      alert("Thou hast clickethed")
   });

 

I have to do this

   $('.result').live("click", function() {
      alert("Thou hast clickethed")
   });

 

schwew..I feel so much better now.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.