Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4572310
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:37:41+00:00 2026-05-21T19:37:41+00:00

I figure i’ve just been staring at my screen too long today – I

  • 0

I figure i’ve just been staring at my screen too long today – I can’t find the error here. I’ve got a jQuery template and i’m using KnockoutJS’s foreach on it. Inside i have a button and i’m trying to call a function onclick and pass in an iteration value. Here’s the snippet from the template. The only thing that i can think would be wrong is something about my jQuery template syntax, tho it’s working elsewhere
<button onclick="newTabify(${$data})">Chat</button>

My template looks like this…(the button’s inside, along with a bunch of other stuff)

 <div data-bind='template: {name: "contactTemplate", foreach:contacts}' id="contactList"></div>
<script id='contactTemplate' type='text/html'>
 ... 
</script> 

The newTabify function looks like:

 function newTabify(contact) {
        tabify($.inArray(contact, viewModel.contacts()));
    }

What’s extremeley odd here is the error.

SCRIPT1007: Expected ']' 
default.html, line 1 character 19

Line 1 is my <head> tag!!

If you need anymore markup just lemme know. Thanks!

EDIT: Here’s my contact template. The funny thing is there’s not a thing wrong with any of it except for the click event on the button when i try to add the line as shown above. But here’s the rest anyways.

{{if $data.jid() != viewModel.jid() }}
    <div class="wrapper" onclick="wrapperClick(this)">
    <div style="padding-bottom:4px">
    <img src=images/${$data.avail}.png> ${ $data.name } <img class="avatar" src=images/${$data.img}><br> <span class="status">${$data.status }</span>
                </div>
        <a href="mailto:${$data.jid}" >${$data.jid}</a> | <button onclick="newTabify(${$data})">Chat</button> | <button onclick="event.stopPropagation();">Call</button>
    </div>
    {{/if}}

EDIT 2: $data a contact object; i’m looping through contacts (an observable array of contact objects) and sucessfully pulling all the values out of contact, etc. Here’s my contact:

function contact(name, status, avail, jid, img, convIndex){
    return {
    name : ko.observable(name),
    status : ko.observable(status),
    avail : ko.observable(avail), 
    img : ko.observable(img),
    jid : ko.observable(jid),
    convIndex: ko.observable(convIndex)
    };

}

So technically $data should be a instanct of the above.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T19:37:43+00:00Added an answer on May 21, 2026 at 7:37 pm

    I can’t guarantee that this is your only problem, but this line is not going to give you what you are expecting:

    <button onclick="newTabify(${$data})">Chat</button>
    

    Doing ${$data} is going to give you the .toString() of your object. For your object it will look like:

    [object Object]
    

    So, this would not be valid syntax.

    Since, you are using Knockout you can instead do something like this (even inside of a template) and it will pass the actual object properly:

    <button data-bind="click: function() { newTabify($data); }">Chat</button>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can't figure out what's happening here. I've got a few lists set up,
I can't figure out why this error in php 5.4. Strict Standards: Non-static method
i have drawed some figure(circle, rectangle or just a line) and after that i
Can't figure what I am doing wrong. When I post my form there are
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
Figure there is a simple solution to this problem but I have been unable
I can't figure out why it's always returning the value of arg1. I'm building
I can't figure out how to handle exception for python 'with' statement. If I
I am trying to figure out how I can hit breakpoints in my unit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.