Jump to content

jimfog

Members
  • Posts

    1,803
  • Joined

  • Last visited

Posts posted by jimfog

  1. I am trying to create an event in backbone...when the user starts typing in an input box a function should be called that emits an alert message.

     

    Take a look at the jsbin here http://jsbin.com/silajo/25/

     

    Find this code (jsbin does not have line numbers so I can guide you with precision):

     this.on("keyup input#name",this.test);  

    Then...click right on the calendar...a popup box will appear with two input elements.

    My tests relate to the title input element.

     

    Normally...when the user starts typing in the title box an alert message should appear....but in my case it does not.

    I do not even get a console error...the code seems not to run at all.

  2. I am getting the familiar backbone model undefined.

     

    I have created a jsbin example here: http://jsbin.com/silajo/15/

     

    In the output pane you will see a calendar....click anywhere so that a popup box appear,enter some data in the input fields.

    Till that point everything goes well....the event is displayed in the calendar.

     

    But if I go yo click the newly created event I get in the console

     

    Cannot read property 'isNew' of undefined.

     

    This message appears when the parser tries to run the code at line 88: if (!this.model.isNew()) {

     

    I know what this message I means but I cannot understand why this emitted.

     

    The problem appeared once I updated backbone to the most recent version....1.1.2

     

    I believe it has something to do with binding the view(the view related to popup box) to the model.

    This view is defined at 78

     

     

    P.S I want to add that the problem disappears when I refresh the page

  3. It looks to me like the "OK" button isn't inside the form and is not submitting the form. The form will probably only validate fields if somebody tries to submit it.

    yes an OK/submit button is needed....the problem in my case though is the fact that despite a submit is needed to make the plugin-

    an actual submit must never take place cause in this case here the data sent to the server are sent with backbone code.

     

    After a search I made a submitHandler http://jqueryvalidation.org/validate#submithandler function might be able to solve the issue-something I have not managed to do yet.

     

    This a jsbin demo http://jsbin.com/gaqamu/5/

     

    Go at see the save function at line 94,with validate code in it(the whole js file of course is backbone code).

     

    Go and click the calendar in the right and a pop up box will appear...press OK-see if the validation message(as defined in the required attribute).

    Currently its behavior is weird....sometimes validation takes place and other times no.

     

    I am still trying to make this work.

  4. I am trying to use jquery validate plugin in combination with backbone and other plugins also(jquery UI component).

     

    The problem is I cannot get it to work...

     

    Take a look at this fiddle.....http://jsfiddle.net/fiddlehunt/zd5P9/ if you click on the calendar in the results pane a dialog box appears with an input named title.

     

    I am trying to set this to be "required" by using jquery validate code found in the bottom of the JS pane...it does not work though.

     

    What can be wrong here?The console does not present any error relevant to the validate plugin,it does present an error though relevant to backbone.js which I do not think affects the jquery validate code.

  5. I have made 2 dropdown menus and I want when the user makes a selection to one of them(for the sake of brevity I do my testing only to the one menu) the selection is highlighted and the highlight immediately removed(fading in other words).

     

    The code with which I am trying to accomplish the above is here http://jsfiddle.net/fiddlehunt/achgnmcv/

     

    I am making my tests with the from menu.

     

    And now my problem...

     

    Despite highlighting takes place(by adding a specific class as you see in the code),when the class is removed, the element(drop menu) is completely hidden from view.

     

    I really cannot explain this behavior....just try to make a selection in the from menu.

     

    How can I fix it?

     

    As I mention again the goal here is that the class/effect is added/removed gradually.

  6. yes I am defining an object...:

       this.eventView.model = new Event({start: Math.round(start.getTime()/ 1000), end: Math.round(end.getTime()/ 1000),allDay:false,color: '#0072C6'});            

    I assume you mean adding properties to the above object.

     

    Yes but how could I implement this....currently I set the values of these globals,check their value(using conditionals) and act accordingly.

     

    How I could do that using object properties?

     

    I am trying to think what re factoring to do?

    Any help would be appreciates...an example maybe?

     

    Do objects have global scope?

  7. I have this code-it is simplified so you can get an easier meaning out of it:

     select: function(start, end,allDay,event,fcEvent) {  monthclick=true;;//global      if(selectmonth===true)//global also here{...}.....   }changefrom: function(){   if(monthclick===true)
    {
    selectmonth=true;
    $('#calendar').fullCalendar('select',start,end,allDay);//this line here calls the select function above
    }

    }

     

    Τhe above code has 2 global variables,selectmonth and monthclick, and the code within changefrom() calls the select function directly above it.

     

    The full code is here at line 60(select function) and line 260 (changefrom function) at this script here http://1drv.ms/1s6sdnG

    Of course the code in the script is much more but I want you to focus on the problem with the global variables.

     

    The existence of globals makes the code more complicated(conditionals...etc)...is this unavoidable or I can do something to avoid it?

     

    Anything...

     

  8. There's also the argument that a good solution today is better than a perfect solution next week.

    And how that relates to this topic?

    Can you be more specific?

    I would like to hear what do you have to say.

  9. If you you need to sort on it, why not?

    There is this argument you know:

     

    Suppose that we have 50k rows with each value appearing on average 10k times.

    An INDEX it seems it cannot help a lot...we are talking here about repeating values(and not distinct) from row to row.

  10. I have create a table with an ENUM column with 5 values in it...and I have INDEX it.

     

    The question is if it is logical to place an INDEX on a column as the above...do you think it is useless?

     

    I think I miss something here.

  11. I have a 3-col table.

     

    One of the columns is INT type.

     

    My problem has to when fetching data from this table.

    The strange thing(I used var_dump to do the testing) that the INT comes as a string

     

    For example in the database table at the specific col there is the value 2.

    Running a SELECT query will bring back "2".

     

    Why this might be happening?

     

    I am not posting any code-yet-cause I do not know if it is going to be of any use.

     

     

  12. well it seems I found a solution to it...a simple one,I just used this syntax to "take" the string from the array an assign it to a separate variable.

    $serve=$service[0];

    With the above, the query worked.

     

    The only thing that remains is how to write the code in case the array contains more than one element....but I will write a different post for that,

    besides I do not think it would be difficult....a for loop for that matter.

     

    Thanks.

  13. This post might be beeb as well to the PHP forum.I was not sure(and I am still not) if this is the proper place for this question,anyway...

     

    I am trying to insert some data to a table...here is the INSERT statement:

     $result=$connection->query('insert into appointments.services_list (servicename,price) values ("'. $serve[0].'","'.$price.'")');         

    When I try to run the above code though I get a notice:array to string conversion problem...

     

    This has to do with the $serve[0] variable...it is an array as you can see,and here specifically,in this example contains a string data type-it is comprised of only one element. I do not want to add more elements for now...

     

    So the question is why do I get this notice?

  14. Here's another clue:

    The error says $appdata is undefined, so we must define it before it is used.

    I defined it outside the while loop and that seems to solve the problem...

      $appdata=array();

    I am going to study the code first and then ask some questions cause I want to realize here what is going on fully.

     

    And again...many thanks.It was very frustrating....

  15. First of all many thanks for the code,it works(3 dimensional array ARE produced)....but with a very small problem.

    I get the following error regarding this code $mapApIDToRowIndex[$appdetails->apID] = count($appdata);//this is at line 35

     

    Notice: Undefined variable: appdata in C:Apache24htdocsAppointmentsAdministratoradmin_db_code.php on line 35

     

    So despite the notice,the job gets done but it would be nice if that was missing of course.

  16.  

    that's what I'm trying to say. the last thing at all is json_encode the whole thing. not items you are pushing. the very last thing I would expect, since you are encoding as JSON presumably for a web service, is

    echo json_encode($myData);

    I got what you said,nonetheless we are dealing here with a different aspect of the problem-long before using json_encode

  17. You can see the code below,as already stated is not correct,I have incorporated your suggestions-only the first while loop is OK:

    function get_appointments($connection,$email)//να μάθω για το μηνυμα που σχετίζεται με το κιτρινο τριγωνακι  {        $connection->set_charset("utf8");        $result=$connection->query('select appointments.name,appointments.apID,staffID,appointments.apps_origin,FROM_UNIXTIME( startDate ) as startDate ,FROM_UNIXTIME( endDate ) as endDate             from appointments,users            where users.email="'.$email.'"            and appointments.bookedfor=users.user_ID');                 if(!$result)        {printf("Errormessage for result: %sn", $connection->error);         return false;}         elseif($result->num_rows>0)                  {          while ($appdetails = $result->fetch_object()){          $appdata[]=['name'=>$appdetails->name,'apID'=>$appdetails->apID,                  'start'=>$appdetails->startDate,'end'=>$appdetails->endDate,'staffID'=>$appdetails->staffID                  ,'origin'=>$appdetails->apps_origin];           }        }                for($i=0;$i < count($appdata);++$i)        {           $result1 = $connection->query('select serviceID from services_list,appoint_servi_chosen               where services_list.serviceID=appoint_servi_chosen.service_ID               and appoint_servi_chosen.app_ID="'. $appdata[0]['apID'].'"');        }             if(!$result1)        {printf("Errormessage for result1: %sn", $connection->error);         return false;        }         elseif($result1->num_rows>0)        {          while($service = $result1->fetch_object())           {            $appdata[0]['service'][] = $service->serviceID;           }        }           return  $appdata;              }

    here is the call:

    $appdetails=get_appointments($conn,$email);
×
×
  • Create New...