mercredi 1 juillet 2015

DataTable Uncaught TypeError: Cannot read property 'cell' of undefined

I have a dataTable with local data consisting of 8 headers/rows. However I'm getting Uncaught TypeError: Cannot read property 'cell' of undefined. I did some investigation and if I comment out only one of the columns then I am not getting error anymore. Seems my table can only show 7 rows. Do you know how to fix this?

Ajax Calls Returning Zero in IE/Firefox

Have been working on this for 2 days and can't figure out what is causing this to fail in IE (v11) and Firefox. Works fine in Chrome.

Read a lot of questions on here that covered caching issues with multiple Ajax calls, particularly with IE, but I don't believe that's the issue. This code is actually one of two forms on the page. Both are submitted via jQuery, when a "Submit All" button is clicked. I disabled the first form, though, and the second still doesn't function properly.

Here's the JS/Ajax code for the faulty form submission:

$("body").on( "submit", ".update-guest-email", function(event) {
    event.preventDefault();
    var form = $(this);

    if( form.find('input[name="email"]').val() == "" ) {
        return;
    }
    if (!formChecker(form)){
        return;
    }

    var dataString = {
        action : 'update_guest_party',
        data : form.serializeArray()
    }

    $.ajax({
        cache: false,
        type: "post",
        url: ajaxurl, // This is the WP AJAX handler.
        data: dataString,
        beforeSend: function() {
            form.find('input').prop('disabled', true);
        },
        success: function(response){ //so, if data is retrieved, store it in response
            if (response.data >= 1){
                form.append('<div class="center confirmed"><span class="dashicons dashicons-yes"></span></div>');
                form.removeClass();
            } else {
                form.find('input').prop('disabled', false);
                $(".errors").html("That's weird; it didn't go through. You can try again or <a href='mailto:email@gmail.com'>send us an email</a>.")
                $('.errors').slideDown(250);
            }
        } // Close success response.
    }); // Close AJAX.
}); // End form-submit.

Again, that functions as expected in Chrome. Firebug shows POST data correctly:

action          update_guest_party
data[0][name]   email
data[0][value]  brundeezy@gmail.com
data[1][name]   table
data[1][value]  dw_wedding_mgr_guests
data[2][name]   id
data[2][value]  149

But then the response is just a '0' (zero). Per Chrome, the response should look like this:

{"success":true,"data":1}

Any help is greatly appreciated! I also have this on a live server, if it would be helpful to see it in production.

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data - tried to parse a php if/else statment

I am building a search which will list a number of users and I am getting this error when I am trying to load more pages to show more users in Chrome dev tool:

Uncaught SyntaxError: Unexpected token <

But I am getting this error in firebug which I think is more conclusive:

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

var result = JSON.parse(res);

Here is my ajax function in my index.volt

function(cb){
        $.ajax({
            url: '/search/search?q=' + mapObject.q + '&sort=<?php echo $sort;?>' +  '&page=' + mapObject.page,
            data:{},
            success: function(res) {
                var result = JSON.parse(res);
                if (!result.status){
                    return cb(null, result.list);
                }else{
                    return cb(null, []);
                }
            },
            error: function(xhr, ajaxOptions, thrownError) {
                cb(null, []);
             }
    });

And here is my searchAction() in my Controller:

public function searchAction()
    {
        $q = $this->request->get("q");
        $sort = $this->request->get("sort");
        $searchUserModel = new SearchUsers();
        $loginUser = $this->component->user->getSessionUser();
        $page = $this->request->get("page");
        $limit = 1;
        if (!$page){
            $page = 1;
        }
        $list = $searchUserModel->findTeachers($q, $loginUser->id, ($loginUser?true:false), $page, $limit, $sort);
        $list['status'] = true;
        echo json_encode($list);
    }

At first I am not sure if the res status is defined so I added $list['status'] = true but it is not helping. Then I tried to remove the if/else statements and it is also not effective.

I need another pair of eyes as I already confirmed all the other variables are valid (ie. $q, $loginUser, $page, $limit, $sort).

Will be greatly appreciated if you can let me know first before downvoting if you think my question is bad or unclear in the comments so I have a change to edit.

Full screen image gallery on click

On http://ift.tt/1ROop3u, I've got a bunch of different pictures.

I want the user to be able to click on an image, then go into a sort of full screen image gallery with arrows going back and forth to switch between images and an X button to go back to the main photography page.

I have separate images on my server that are full resolution.

Would I just make the current images links that go to pages for each of the full screen/resolution images? I feel like there is a much easier way to do this. Any help on the matter would be greatly appreciated!

Thanks for your time!

Trigger events when pageYoffset >= div.offsetTop

I am working on a simple navigation for my site which uses the window.pageYoffset to change the label on the only navigation button which is fixed to the document right, and secondly, click actions on the button scrolls to the top position of the respective container based on the label.

Note:

  1. Container A is dynamic, the height varies based on the height of the images received.
  2. Container B has fixed height, I've not decided on what the height is going to be but to just get this functionality going I've am considering 700px.

How do I calculate pageYoffset, such that label change is triggered only when the pageYoffset >= containerB.offset.top? I'm not sure if this condition is met and I am changing a wild goose or is there a better way to tackle this problem.

Current Solution

This is my current solution but the label change triggers when the scrollbar is not even close to the topPosition of ContainerB. I've attached a image which depicts the page.

window.addEventListener( "optimizedScroll", function optimizedScrollFunc( ) {
    var self = voApp,
        gotoTop = document.getElementById( "cc-gototop-js" ),
        winPageYOffset = window.pageYOffset,
        windowInnerHeight = window.innerHeight,
        documentScrollHeight = document.body.scrollHeight,
        topStoriesLoadMore = document.getElementById( "cc-tsLoadMoreWrapper-js" );
        dom.glanceUIDiv = document.getElementById( "cc-glanceWrapper-js" ).offsetTop;

    console.log((winPageYOffset + windowInnerHeight), documentScrollHeight);

    if ( winPageYOffset + windowInnerHeight >= documentScrollHeight ) {
        console.log("FIRED");
        $( gotoTop )
            .removeClass( "cc-thisWeek" )
            .addClass( "cc-today" );
        $( topStoriesLoadMore )
            .removeClass( "cc-tsLoadMoreWrapperVisible" );
    }
    if ( winPageYOffset < 200 ) {
        $( gotoTop )
            .removeClass( "cc-today" )
            .addClass( "cc-thisWeek" );
    }
} );
appUtil.f_throttle( "scroll", "optimizedScroll" );

Page Wireframe

enter image description here

Google Charts - MySQL php

hope all is well!


I need some guidance I have a MySQL Table which looks like this


enter image description here

I would like to have a drop-down list of the companies (facebook, google and youtube) - When I select for example: "google" from the drop-down list, it would display the results for each username who has "google in their row. Then count how many there are total for each user. I would like to have the results show for each day, a full month and a full year totals. It would also be very nice to somehow show each time each company was hit by that user. That's why I added the timestamp.

I would want this to show in some kinda nice graph bar chart. I thought of using Google Charts. Maybe there is something better? Maybe easier to work with?

I'm not here posting this to ask for someone to just code this for me, i'm asking for some help to start me out! Any help is appreciated!

I hope this make sense! haha. This seems very complicated for me to code but I love a challenge but I'm pulling my hair out trying to figure this one out.



Thank you,
Timothy

jQuery: How to add the attribute in $(this)?

Example I have 10 textbox and each has the same attribute with different value, say for example they have an attribute data-same with different value and I have something like this in my code
$('#test').each(function(){ $(this).val(); });
and I want to filter the result using the attribute of each textbox. How would I do it? I was thinking on doing something like this
$('#test').each(function(){ $('[data-same="val1"]',this).val(); });
but I'm not sure about it.