Cannot get submit button to POST or Autocomplete to fill
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/Librar开发者_StackOverflow中文版y/Offer.class.php
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
}
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.
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)
精彩评论