无法使用jquery

时间:2015-08-04 06:26:17

标签: jquery internet-explorer

我有一个场景,我将从文本框的选项中选择一个值,当我输入选定的值时,它将移动到下一张幻灯片。这在IE中不起作用。我已经使用了keyup事件,但这不会满足,因为无论何时值是类型,如果它在被选中之前与任何值匹配,它将转移到下一张幻灯片。我不想要这个。我必须按Enter键选择一个值。

这是我实际的onchange代码

$("#newstaggered-carousel input[name='otherCityInputField']").on('change', function() {

密钥代码

$("#newstaggered-carousel input[name='otherCityInputField']").on('keyup',function() {

1 个答案:

答案 0 :(得分:0)

您可以使用$('#newstaggered-carousel input[name='otherCityInputField']').on('keyup',function(e){ if(e.keyCode == 13) { //move to next slide use your code } }); 事件并检查是否输入了密钥代码。像:

input

或者您可以使用$('#newstaggered-carousel input[name='otherCityInputField']').on('input',function(e){ if(e.keyCode == 13) { //move to next slide use your code } }); 事件

public class EventsAdapter extends ArrayAdapter<Article> {

    EventsAdapter adapter = this;
    Context context;
    int layoutResourceId;
    ArrayList<Article> cartItems = new ArrayList<Article>();
    Date time;

    public EventsAdapter(Context context, int layoutResourceId,
                         ArrayList<Article> galleries) {
        super(context, layoutResourceId, galleries);
        this.layoutResourceId = layoutResourceId;
        this.context = context;
        this.cartItems = galleries;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        final Article eventItem = getItem(position);
        if (convertView == null) {
            convertView = LayoutInflater.from(getContext()).inflate(R.layout.event_item_row, parent, false);
        }

        Typeface cFont2 = Typeface.createFromAsset(context.getAssets(), "fonts/berthold_baskerville_bold-webfont.ttf");
        final RecordHolder holder = new RecordHolder();
        holder.eventImage = (ImageView) convertView.findViewById(R.id.event_image);
        holder.eventTitle = (TextView) convertView.findViewById(R.id.event_title);
        holder.eventTitleDescription = (TextView) convertView.findViewById(R.id.event_title_description);
        holder.eventCountries = (TextView) convertView.findViewById(R.id.event_countries);
        holder.eventRegions = (TextView) convertView.findViewById(R.id.event_regions);
        holder.eventCategory = (TextView) convertView.findViewById(R.id.event_category);
        holder.eventType = (TextView) convertView.findViewById(R.id.event_type);
        holder.eventDate = (TextView) convertView.findViewById(R.id.event_date);
        holder.salary = (TextView) convertView.findViewById(R.id.job_salary);
        holder.eventTitle.setTypeface(cFont2);
        holder.salary.setVisibility(View.GONE);
        holder.eventImage.setVisibility(View.GONE);
        if (!eventItem.getImageURL().equals("")) {
            holder.eventImage.setVisibility(View.VISIBLE);
            Picasso.with(context)
                    .load(eventItem.getImageURL())
                    .resize(250, 175)
                    .into(holder.eventImage);
        }
        holder.eventTitle.setText(eventItem.getName());

        if (eventItem.getCountry() == null) {
            holder.eventCountries.setText(context.getString(R.string.all_countries));
        } else {
            holder.eventCountries.setText(eventItem.getCountry().getName());
        }
        if (eventItem.getRegion() == null) {
            holder.eventRegions.setText(context.getString(R.string.all_regions));
        } else {
            holder.eventRegions.setText(eventItem.getRegion().getName());
        }

        boolean startDate = false;
        boolean endDate = false;
        String endDateString = "";
        String startDateString = "";
        for (int i = 0; i < eventItem.getExtraFields().size(); i++) {
            if (eventItem.getExtraFields().get(i).getName().equals("EVENTENDDATE") && !eventItem.getExtraFields().get(i).getValue().getValue().equals("")) {
                endDate = true;
                endDateString = new SimpleDateFormat("dd/MM/yyyy").format(getDate(eventItem.getExtraFields().get(i).getValue().getValue()));
            }
        }
        for (int i = 0; i < eventItem.getExtraFields().size(); i++) {
            if (eventItem.getExtraFields().get(i).getName().equals("EVENTSTARTDATE") && !eventItem.getExtraFields().get(i).getValue().getValue().equals("")) {
                startDate = true;
                startDateString = new SimpleDateFormat("dd/MM/yyyy").format(getDate(eventItem.getExtraFields().get(i).getValue().getValue()));
            }
        }

        if (startDate && endDate) {
            holder.eventDate.setText(startDateString + " - " + endDateString);
            holder.eventDate.setVisibility(View.VISIBLE);
        } else if (startDate) {
            holder.eventDate.setText(startDateString);
            holder.eventDate.setVisibility(View.VISIBLE);
        } else {
            holder.eventDate.setVisibility(View.VISIBLE);
        }

       for (int i = 0; i < eventItem.getExtraFields().size(); i++) {
            if (eventItem.getExtraFields().get(i).getName().equals("EVENTORGANISER")) {
                holder.eventTitleDescription.setText(eventItem.getExtraFields().get(i).getValue().getValue());
            } else if (eventItem.getExtraFields().get(i).getName().equals("EVENTTYPE")) {

                holder.eventType.setVisibility(View.VISIBLE);
                holder.eventType.setText(eventItem.getExtraFields().get(i).getValue().getValue());
            }

        }
        holder.eventCategory.setText(eventItem.getCategories().get(0).getName());

        return convertView;
    }


    private Date getDate(String date) {

        String json = date;
        String timeString = json.substring(json.indexOf("(") + 1, json.indexOf(")"));
        String[] timeSegments = timeString.split("\\+");
        // May have to handle negative timezones
        int timeZoneOffSet = Integer.valueOf(timeSegments[1]) * 36000; // (("0100" / 100) * 3600 * 1000)
        long millis = Long.valueOf(timeSegments[0]);
        time = new Date(millis + timeZoneOffSet);
        return time;
    }

    static class RecordHolder {
        TextView salary;
        ImageView eventImage;
        TextView eventTitle;
        TextView eventTitleDescription;
        TextView eventCountries;
        TextView eventRegions;
        TextView eventCategory;
        TextView eventType;
        TextView eventDate;
    }
}