2013-04-13 6 views
-1

im, создающий хром-расширение google и im, имеющее некоторые проблемы. У меня есть объектный файл, представляющий форму и его действия. моя проблема в том, что я использую объект, что-то ломается, и никакой код в файле сценария не запускается.Устранение неполадок Файл Javascript

здесь файл Форма объекта:

/// <reference path="../Jquery1.6_vsdoc/ChromeExtenVSdoc.js" /> 
/// <reference path="../Jquery1.6_vsdoc/jquery-vsdoc.js" /> 

function FormInputObject() { 

this.BusinessName = ""; 
this.ShortDesc = ""; 
this.LongDesc = ""; 
this.Location = ""; 
this.ContactName = ""; 
this.Telephone = ""; 
this.CellPhone = ""; 
this.FaxNumber = "" 
this.Adress = ""; 
this.City = ""; 
this.BusinessEmail = ""; 
this.WebSiteAdress = ""; 
this.Keywords = ""; 

this.PrivateName = ""; 
this.PrivateTelepone = ""; 
this.PrivateEmail = ""; 


//get user data from the INPUT html 
this.GetInputFormDocument = function (document) { 

    this.BusinessName = $("name"); 
    this.ShortDesc  = $("descriplittle"); 
    this.LongDesc  = $("descrip"); 
    this.Location  = $("area"); 
    this.ContactName = $("contactman"); 
    this.CellPhone  = $("pelephone"); 
    this.FaxNumber  = $("fax"); 
    this.Adress  = $("adr"); 
    this.City   = $("city"); 
    this.BusinessEmail = $("email"); 
    this.WebSiteAdress = $("www"); 
    this.Keywords  = $("keywords"); 

    this.PrivateName  = $("firstname1"); 
    this.PrivateTelepone = $("phone1"); 
    this.PrivateEmail = $("email1"); 
} 

this.ClearForm = function (document) { 


    this.ShortDesc   .text(""); 
    this.LongDesc   .text(""); 
    this.Location   .text(""); 
    this.ContactName  .text(""); 
    this.CellPhone   .text(""); 
    this.FaxNumber   .text(""); 
    this.Adress   .text(""); 
    this.City    .text(""); 
    this.BusinessEmail  .text(""); 
    this.WebSiteAdress  .text(""); 
    this.Keywords   .text(""); 

    this.PrivateName  .text(""); 
    this.PrivateTelepone .text(""); 
    this.PrivateEmail  .text(""); 
} 



    //sending only the object fields 
    this.sendFormFields = function (command) { 
     chrome.extension.sendRequest(null, 
      { 
       input   : command   , 
       BusinessName : this.BusinessName , 
       ShortDesc  : this.ShortDesc  , 
       LongDesc  : this.LongDesc  , 
       Location  : this.Location  , 
       ContactName : this.ContactName , 
       CellPhone  : this.CellPhone  , 
       FaxNumber  : this.FaxNumber  , 
       Adress   : this.Adress  , 
       City   : this.City   , 
       BusinessEmail : this.BusinessEmail , 
       WebSiteAdress : this.WebSiteAdress , 
       Keywords  : this.Keywords  , 

       PrivateName  : this.PrivateName , 
       PrivateTelepone : this.PrivateTelepone, 
       PrivateEmail  : this.PrivateEmail 
      }, 
      function (response) { 

      }); 

    } 

    //sending all of the object 
    this.sendTheFormObject = function() { 
     chrome.extension.sendRequest(null, 
      { 
       FormInputObject: this 
      }, 
      function (response) { 

      }); 
    } 
} 

здесь файл сценария, где я использую объект:

/// <reference path="../ChromeExtenVSdoc.js" /> 
/// <reference path="../Jquery1.6_vsdoc/jquery-vsdoc.js" /> 
/// <reference path="FormInputObject.js" /> 

//if i comment this line out, there is no problems and the alerts 
//i call in the file run fine 
var formInput = new FormInputObject(); 

$(document).ready(function() { 


$("#sendData").click(null, function() { 

    formInput.GetInputFormDocument(document); 

    formInput.sendFormFields("justFillOutFourm"); 

}); 

$("#clearForm").click(null, function() { 
    formInput.ClearForm(document); 
    alert("asdf"); 

}); 
alert("asdf"); 

});

Я уверен, что у меня есть проблема с моим объектом, но я понятия не имею, что это такое. (извините за мой английский)

EDIT: это как refrence файлы на HTML:

<head> 
    <title></title> 
    <script src="../Jquery1.6_vsdoc/jquery-1.7.1.min.js" type="text/javascript"></script> 
    <script src="input_page.js" type="text/javascript"></script> 
    </head> 
+2

Вы проверили консоль ошибок? Если что-то сломается, там будет сообщено об исключении. –

+0

не думал об этом. он говорит, что FormInputObject не определен. wierd, я инициализирую путь worng? – samy

ответ

1

Move var formInput = new FormInputObject(); после документа готов. Также убедитесь, что вы включаете jquery.js, и что вы включаете его перед любым другим JS, который его требует.

+0

просто попробовал, и я все равно получаю ту же ошибку. любые другие идеи? – samy

+0

Любые ошибки консоли? – Mooseman

+0

Да, я получаю: Непринятый ReferenceError: FormInputObject не определен – samy

Смежные вопросы