1

my application updated some of the framework as well as jquery and now doesn't work. I'm not sure what to do since I'm not getting useful information back to debug. Here's what I am looking for:

GIVEN: I am on the selected page with a text field and submit button WHEN: I type a few letters in the textbox THEN: I want Autocomplete with available accounts matching values from the database.

GIVEN: I see a value that I want to add to my list WHEN: I click "Add" THEN: I want to see the selected value displayed in the panel via Ajax (no need to refresh the page):

Here is the code for the Autocompletion:

    $this->btnAddOffer = new QButton($this->pnlAddOffer,"btnAddOffer");

    $this->btnAddOffer->CssClass =  "button";

    $this->btnAddOffer->Text = "Add";
    $this->txtNewOffer->AddAction(new QEnterKeyEvent(), new QAjaxAction('btnAddOffer_Click'));
    $this->txtNewOffer->AddAction(new QEnterKeyEvent(), new QTerminateAction());

    $this->btnAddOffer->AddAction(new QClickEvent(), new QAjaxAction('btnAddOffer_Click'));

and:

protected function btnAddOffer_Click($strFormId, $strControlId, $strParameter) {
    if($this->txtNewOffer->Text == ''){

        $this->txtNewOffer->Warning = "You must be enter a offer company name!";
        return false;

    }
    $objUser = unserialize($_SESSION['User']);

    $objAccount = Account::LoadByName($this->txtNewOffer->Text);

    if($objAccount){
        $objUser->AccountId = $objAccount->Id;
        $objOffer = Offer::LoadByUserOwnerIdAccountId($objUser->Id,$objAccount->Id);
        if($objOffer){

            QApplication::DisplayAlert("This account already exists!!");

        } else {

            $objOffer = new Offer();
            $objOffer->UserOwnerId = $objUser->Id;
            $objOffer->AccountId = $objAccount->Id;
            $objOffer->Save();

            #QApplication::DisplayAlert("New account was added successfully");
        }
    }

The current outcomes that I get:

  • When I type in the textbox, I see an empty form with the following Firebug:

alt text http://img707.imageshack.us/img707/5102/screenshot2162010102232.png

I'm not sure what to do since I have no information to debug what is going on.

Here is a screenshot using Firebug of the code-generated around the input box and the submit button:

alt text http://img535.imageshack.us/img535/9148/screenshot292010113245a.png

The related code in the controller:

More details can be found here:

http://github.com/allyforce/AF-upload/blob/master/Library/Offer.class.php

Satchel
  • 16,414
  • 23
  • 106
  • 192
  • Can you provide an example page? – Marcel Korpel Feb 09 '10 at 20:07
  • yeah, let me fix these pages and see if I can do that. – Satchel Feb 10 '10 at 19:33
  • @Angela: Huh? I just asked for an example page, because I cannot do much with a Firebug screenshot. – Marcel Korpel Feb 11 '10 at 14:17
  • you mean a screenshot or the URL to a live page? – Satchel Feb 17 '10 at 01:18
  • Doesn't look like AutoComplete code to me, looks like the event handlers for btnAddOffer. What AutoComplete code are you using? There was an example of using jQuery AutoComplete posted on the QCodo forums a while back which I ended up using in my project. It gives you a QAutoCompleteTextBox control, which in turn provides a QAutoCompleteTextBoxEvent. On calling this event, it returns (via echo) each element in an array of entries that match the text typed so far (using a QQuery). Let me know if you're using this approach (or want to!) and I'll post up some sample code as an answer – Rob Cowell Feb 17 '10 at 07:46
  • Ok, had a look at the code in your Git repository and you are indeed using QAutoCompleteTextBox. I did notice you'd wired up the QAutoCompleteTextBoxEvent twice (once without a wait icon, once with). I'd try narrowing it down to one. Also, in the event it calls, try putting a QAlert or an echo just to signify the code is hitting this point. Same goes for the btnAddOffer_Click event code. Sounds like it could be related to your other question at http://stackoverflow.com/questions/2216371/autocomplete-in-php-framework-doesnt-seem-to-work-any-longer – Rob Cowell Feb 17 '10 at 07:57
  • Ahah, thanks Rob....btw, do you primarily use SO or are you on any of the qcubed/qcodo forums as well (or not use those frameworks at all?) Thanks so much, we've been struggling with this like crazy. – Satchel Feb 19 '10 at 18:56
  • Hmm, I didn't notice that it was wired up twice, I'm going back through it. I think we commented out one version, but maybe it's still being called somewhere. Do you recommend a different/better way to do autocomplete? – Satchel Feb 24 '10 at 22:22

3 Answers3

1

Have you defined a method for the event to call. Looking at your screenshot, you're using a QAjaxAction rather than a QServerAction, but have you told it the method to call, for example :-

$this->btnAddOffer->AddAction(new QClickEvent(), new QAjaxAction('btnAddOffer_click'));

and then

protected function btnAddOffer_click()
{
    // submit code you want here
}
Rob Cowell
  • 1,610
  • 3
  • 18
  • 34
  • Ah, one of the two people in the universe who uses QCodo! Awesome, thanks. I will put my code above – Satchel Feb 17 '10 at 01:47
  • Think we got it..thanks! Do you still use QCodo as a primary framework or do you use something else as an option or alternative? Thanks! – Satchel Mar 09 '10 at 00:09
  • Still use it when I'm doing PHP stuff, but I'm primarily a .Net developer. PHP is my sideline ;-) – Rob Cowell Mar 12 '10 at 13:37
0

Do you have any javascript or CSS that might be hiding the id "btnAddOffer_ctl". That would be the first thing I'd search for. In the source do a find for the string bntAddOffer_ctl. Chances this id either has its visibility CSS set to hidden.

You could also have a JavaScript section that might look like this:

document.getElementByid('btnAddOffer_ctl').style.visibility = 'hidden'; 

or

document.btnAddOffer_ctl.visibility = 'hidden'; 

Hope that helps.

  • I could be wrong, but I think the issue is that the event attached to the button is not firing, rather than the button not displaying – Rob Cowell Feb 16 '10 at 16:05
  • Yes, Rob, you're eright, it is because the event on the button is not firing....! – Satchel Feb 17 '10 at 01:17
0

Change the button type to submit instead of "button" (or be sure whatever action assigned to "button" does what you want it to do- because we can't see what the function is supposed to invoke with this picture)

Ryan
  • 768
  • 4
  • 15