小编San*_*eph的帖子

Angular获取选中的CheckBoxes

我有一个使用angular的动态填充复选框列表.

 <div ng-repeat="X in XList">
     <label>{{X.Header}}</label>
     <input type="checkbox" name="X" value="{{X.Item.Id}}" />
     <p>{{X.Header}}</p>
 </div>
Run Code Online (Sandbox Code Playgroud)

我想要一个方法来检索所有选中的复选框的列表.通常我会用

 $('input[name=checkboxlist]:checked').each(function()
{
}
Run Code Online (Sandbox Code Playgroud)

但这对于角度来说是不可接受的....那么有适当的方法吗?

javascript checkbox checkboxlist angularjs

16
推荐指数
1
解决办法
2万
查看次数

在下拉框中选择项目时更改文本框值

我正在尝试使用从下拉框中选择的项目更改文本框的值.但它不起作用.

我试过这个HTML:

<select name="ncontacts" id="contacts" onchange="ChooseContact(this);"> 
</select>
Run Code Online (Sandbox Code Playgroud)

这个JS:

function ChooseContact(data)
{
   alert(data);
   document.getElementById("friendName").value = data;
}
Run Code Online (Sandbox Code Playgroud)

但是文本框val没有更新.

html javascript select

9
推荐指数
1
解决办法
9万
查看次数

检查是否选中了JQuery mobile复选框

我有一个复选框列表,我想获得每个复选框的状态.清单在这里:

<div data-role="fieldcontain">
    <fieldset data-role="controlgroup">
       <input type="checkbox" name="Sunday" id="Sunday-1" class="custom" />
       <label for="Sunday-1">Sunday</label>
       <input type="checkbox" name="Monday" id="Monday-1" class="custom" />
       <label for="Monday-1">Monday</label>
       <input type="checkbox" name="Tuesday" id="Tuesday-1" class="custom" />
       <label for="Tuesday-1">Tuesday</label>
  </fieldset>
</div>
Run Code Online (Sandbox Code Playgroud)

我通常使用此引号检查复选框的状态:

var isChecked = $('#CheckboxID').is(':checked');

但在我的情况下,是否有一种方法可以立即获取"Jquery Mobile"复选框的状态?

javascript checkbox jquery jquery-mobile

8
推荐指数
1
解决办法
3万
查看次数

从下拉列表中选择多个值

我有一个下拉列表,其中包含移动设备上的所有联系人.我想一次选择多个联系人.

当我在常规的html和JS页面上工作时,我使用了这段代码:

     function loopSelected()
     {
      var txtSelectedValuesObj = document.getElementById('txtContactsName');
      var selectedArray = new Array();
      var selObj = document.getElementById('AllContacts');
      var i;
      var count = 0;
      for (i=0; i<selObj.options.length; i++) 
      {
         if (selObj.options[i].selected) {
         selectedArray[count] = selObj.options[i].value;
        count++;
       }
     }
     txtSelectedValuesObj.value = selectedArray;
  }
Run Code Online (Sandbox Code Playgroud)

但是当我在Android上使用它时,会if statement被跳过并且它会停止,这句话:

    "selObj.options[i].selected" 
Run Code Online (Sandbox Code Playgroud)

手机似乎很奇怪!

html javascript android cordova drop-down-menu

6
推荐指数
1
解决办法
2913
查看次数

下载文件错误2,FileTransferError.INVALID_URL_ERR

我正在使用Phonegap [cordova 1.7.0]使用Xcode [ios5]下载文件.这是我用来下载文件的代码:

   function downloadfile(){
   var fileTransfer = new FileTransfer();
   console.log('the type of root is:');
   fileTransfer.download(
                  "http://184.172.195.202:90/ElmNoor/Documents/1.txt",
                  persistent_root.fullPath,
                  function(entry) {
                  alert("I'm Downloading");
                  console.log("download complete: " + entry.fullPath);
                  },
                  function(error) {
                  alert("I'm not downloading");
                  console.log("download error source " + error.source);
                  console.log("download error target " + error.target);
                  console.log("upload error code " + error.code);
                  }
                  );}
Run Code Online (Sandbox Code Playgroud)

但我得到错误代码2我不知道我可以解决它吗?

这是我的日志:

     HelloPhoneGap[933:13403] File Transfer Finished with response code 200
     HelloPhoneGap[933:13403] [INFO] download error source http://184.172.195.202:90/ElmNoor/Documents/1.txt
     HelloPhoneGap[933:13403] [INFO] download error target /Users/weekend/Library/Application Support/iPhone Simulator/5.1/Applications/A7883F4B-7678- …
Run Code Online (Sandbox Code Playgroud)

javascript xcode http-response-codes cordova

6
推荐指数
1
解决办法
6841
查看次数

使用Phonegap访问文件

我正在尝试使用Phonegap [cordova 1.7.0]处理IOS上的文件.我阅读了如何访问文件并在手机缺口的API文档中阅读它们.但是我不知道,当文件被读取时会写在哪里?&如何在iPhone屏幕上输出文本,图像或其他文本?

这是我正在使用的代码:

    function onDeviceReady() {
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}

function gotFS(fileSystem) {
    fileSystem.root.getFile("readme.txt", null, gotFileEntry, fail);
}

function gotFileEntry(fileEntry) {
    fileEntry.file(gotFile, fail);
}

function gotFile(file){
    readDataUrl(file);
    readAsText(file);
}

function readDataUrl(file) {
    var reader = new FileReader();
    reader.onloadend = function(evt) {
        console.log("Read as data URL");
        console.log(evt.target.result);
    };
    reader.readAsDataURL(file);
}

function readAsText(file) {
    var reader = new FileReader();
    reader.onloadend = function(evt) {
        console.log("Read as text");
        console.log(evt.target.result);
    };
    reader.readAsText(file);
}

function fail(evt) {
    console.log(evt.target.error.code);
}
Run Code Online (Sandbox Code Playgroud)

javascript iphone ios5 cordova

5
推荐指数
2
解决办法
2万
查看次数

使用Phonegap访问Android上的联系人

我正在使用手机间隙开发应用程序.我正试图访问移动设备上的联系人,因为我稍后会使用它们.我现在正在尝试编写代码以在移动设备上查找联系人.这是我正在使用的JS文件:

alert('Starting JS');
var TAP = ('ontouchend' in window) ? 'touchend' : 'click';
alert('I entered the function'); 

   document.addEventListener('DOMContentLoaded', function () {
   alert('I entered the second function');

       x$('#friendSubmit').on(TAP, function () {
           var filter = x$('#friendName')[0].value;
           alert('I entered the third function');

           if (!filter)
            {
            alert('Cant find contacts');

                // no contents
                return;
            } 
           else 
           {
              findContactByName(filter, function (contacts) 
              {

   alert(contacts.length + ' contact(s) found matching "' +filter + '"');
  }
); }               

  }); });
  function findContactByName(name, callback) {
       function onError() {
           alert('Error: unable …
Run Code Online (Sandbox Code Playgroud)

html javascript android cordova

4
推荐指数
1
解决办法
1万
查看次数

使用toggleclass在3个类之间切换

我想要切换3张图像.我把它们中的每一个放在一个类中并在css中更改它的图像.我现在可以在两个类之间切换,但是当我添加第三个类时,代码不起作用.它们中的任何一类都可以作为起始类.

    $('.one').click(function(){                             
        $(this).toggleClass("two");
        $(this).toggleClass("one");

    });
     $('.two').click(function(){                             
        $(this).toggleClass("one");
        $(this).toggleClass("two");

    });
Run Code Online (Sandbox Code Playgroud)

当我添加这一行时:

        $(this).toggleClass("three"); 
Run Code Online (Sandbox Code Playgroud)

它根本没有切换....

你知道一种方法,我可以将它们全部放在一个函数中吗?

谢谢.

html javascript jquery toggleclass

4
推荐指数
1
解决办法
5456
查看次数

如何在localStorage中增加值

我有一些动态存储在localStorage的值,增量值如下:localStorage ["Value0"],localStorage ["Value1"],....

当我尝试像这样访问它们时:

JavaScript的:

localStorage["Counter"]=0;
var i = localStorage["Counter"]; 
var d =localStorage["Value"+i];
i = i + 1; // i becomes "01"
var f = localStorage["Value"+i];
Run Code Online (Sandbox Code Playgroud)

i的值是"01"而不是1 ...有没有办法正确增加i的值?

html javascript html5 local-storage

4
推荐指数
1
解决办法
1万
查看次数

Cordova Local Notification Android插件2.2升级

我正在Android上使用Phonegap [Cordova 2.2]开发"Reminders"应用程序.

用户输入提醒的具体日期,我应该按时通知他.

我使用Android的Notification Plugin,但它支持早期版本的手机差距.我按照本教程解决了cordova 2.2和之前的冲突,现在已经解决了很多问题,但我仍然无法解决一些问题:

    public PluginResult execute(String action, JSONArray optionsArr, String callBackId) {
    alarm = new AlarmHelper(cordova.getActivity());
    Log.d(PLUGIN_NAME, "Plugin execute called with action: " + action);

    PluginResult result = null;

    final AlarmOptions alarmOptions = new AlarmOptions();
    alarmOptions.parseOptions(optionsArr); 
Run Code Online (Sandbox Code Playgroud)

这个函数有这个问题:

       public PluginResult execute(String action, JSONArray optionsArr, String callBackId) 
Run Code Online (Sandbox Code Playgroud)

当我用这条线替换它时:

public boolean execute(String action, JSONArray optionsArr, CallbackContext callbackContext) {
Run Code Online (Sandbox Code Playgroud)

错误已修复,但此函数显示另一个错误:

persistAlarm(alarmId, optionsArr);
        return this.add(daily, title, subTitle, ticker, alarmId, alarmOptions.getCal());
    } else if (action.equalsIgnoreCase("cancel")) {
        unpersistAlarm(alarmId);
        return this.cancelNotification(alarmId);
    } else if …
Run Code Online (Sandbox Code Playgroud)

android localnotification phonegap-plugins cordova cordova-2.0.0

3
推荐指数
1
解决办法
5063
查看次数